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,555 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: Template typedef and ternary operato   
   24 Sep 12 00:56:27   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2012-09-24 06:25, fmatthew5876 wrote:   
   > I want to implement an optimization at compile time based on whether   
   > the size of a pointer is large enough to store an object. Without   
   > trying to explain it, I'll just show some code.   
      
   [..]   
      
   > typedef _Foo<   
   > sizeof(void*) < sizeof(uint64_t)   
   > ? SlowBar   
   > : FastBar> Foo;   
   >   
   > The compiler complains about the ternary operator in the typedef.   
      
   The complain makes sense. There is no conditional operator for types   
   (What would be the common type?). In this case the most simple solution   
   is to use the std::conditional type trait:   
      
   typedef _Foo<   
   std::conditional::type> Foo;   
      
   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