home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,137 of 33,346   
   =?windows-1252?Q?Daniel_Kr=FCgler?= to All   
   Re: What type "T" or "auto" should I use   
   14 Apr 12 14:36:28   
   
   00a7afab   
   From: daniel.kruegler@googlemail.com   
      
   Am 14.04.2012 20:34, schrieb Thiago Adams:   
   [..]   
   > Back to is_zero algorithm, let's say I use the same type of digits.   
   >   
   > template   
   > bool is_zero(const number&  n)   
   > {   
   >     using T = decltype(n.digits());   
   >     for (T i = 0 ; i<  n.digits(); i++)   
   >     {   
   >       if (n[i] != 0)   
   >         return false;   
   >     }   
   >     return true;   
   > }   
   >   
   > If T is unsigned char, wouldn’t be better for speed   
   > to use a int i?   
     >   
     > Following the advice use int always you can, otherwise use long long.   
     > I could have traits to be like advices about what type to use.   
     > But, I think it's more interesting to have "auto-advice" "auto select"   
     > types.   
     >   
     > The others algorithms (sum etc) are more interesting.   
      
   You can combine the best of both worlds when referring to   
      
   boost::integral_promotion::type   
      
   instead.   
      
   HTH & Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca