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,324 of 33,346    |
|    Seungbeom Kim to Thiago Adams    |
|    Re: Getting the smallest signed type tha    |
|    22 May 12 11:40:43    |
      044cebfd       From: musiphil@bawi.org              On 2012-05-16 10:38, Thiago Adams wrote:       >       > I think we can solve the problem having a conversion table       > for all integral types. The table is built considering some       > criteria. In your case I think int32 is fine for all cases,       > unless you need int64.       >       > [unsigned char, unsigned chart] -> int       > [unsigned short, unsigned short] -> int       > ....more...       > [unsigned long long, unsigned long long] -> long long              This is not a portable solution because you don't know whether int       will be sufficient for unsigned char or unsigned short; it could be       that sizeof(char) = sizeof(short) = sizeof(int) < sizeof(long) and       that you need to cast unsigned char to signed long.              This is a property of the C++ implementation, so the implementation       trivially knows the solution to this problem, but it's quite hard to       come up with a satisfying solution in a user code; it's just like       trying to invent int_least32_t on your own (without |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca