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 |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca