Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why same types are different?

Why this (char is signed on my implementation):

cout << std::is_same< char,signed char>::value;

outputs false?

like image 702
There is nothing we can do Avatar asked Dec 05 '25 16:12

There is nothing we can do


1 Answers

The three types were introduced at different times.

From the C99 Rational:

Three types of char are specified:
signed, plain, and unsigned. A plain char may be represented as either signed or unsigned depending upon the implementation, as in prior practice. The type signed char was introduced in C89 to make available a one-byte signed integer type on those systems which implement plain char as unsigned char.

They have to stay separate types in C++, to allow overloading on char to be portable.

like image 96
Bo Persson Avatar answered Dec 08 '25 04:12

Bo Persson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!