How should standard C ++ input output streams handle intXX_t types?

According to the answers to these questions, is overloading on all major integer types sufficient to capture all integers? overload of all basic types may not handle type int8_t int64_t, etc. On the other hand, according to the documentation of std :: ostream formatted output and std :: istream formatted input is implemented exactly by overloading all the basic types. So, on a platform where int8_tothers could not handle such congestion, how would C ++ threads have to handle them? Is this not compiling? Should standard library developers provide additional undocumented methods? Something else?

+3
source share
2 answers

For integer types, [istream] defines:

basic_istream<charT,traits>& operator>>(bool& n);
basic_istream<charT,traits>& operator>>(short& n);
basic_istream<charT,traits>& operator>>(unsigned short& n);
basic_istream<charT,traits>& operator>>(int& n);
basic_istream<charT,traits>& operator>>(unsigned int& n);
basic_istream<charT,traits>& operator>>(long& n);
basic_istream<charT,traits>& operator>>(unsigned long& n);
basic_istream<charT,traits>& operator>>(long long& n);
basic_istream<charT,traits>& operator>>(unsigned long long& n);

Any form code is >> xmay not compile if it xis an integer type that is not specified in this list.

As a problem with implementation implementation, an implementation offering extended integer types may add overloads operator>>for these types. This is allowed by [member.functions] / 2 (as noted by hvd in the comments), speaking of classes in the standard library:

An implementation may declare additional non-virtual signatures of member functions within the class:

[...]

  • by adding a member function signature for the member function name.

-, ++, , --.

, , , . SFINAE .


, , , .

+4

, , int8_t , ++?

( < <), ++. - .

, int8_t , . , int8_t - , , .

(operator>>) const , . , , operator>>, .

, , , , .

, ++ 17 to_chars from_chars , ( char). , .

?

. int8_t , , , . , , .

, , int_least64_t intmax_t , long long. . .

, .

?

. , , .


int8_t - - , .

char . , iostream char - , . / . , .

int8_t signed char char, . , .

int8_t , char. , , , . .

+1

Source: https://habr.com/ru/post/1666278/


All Articles