简体   繁体   中英

c++20 and float endianness

Short:

  • Does the c++20 endian proposal only deal with integer types, or does it also give information on float types?
  • Will it add useful standard library functions for dealing with endianness?

Dealing with serialization correctly across platforms is difficult, and the weird possibilities of float endianness are even more frustrating (curses to whoever decided ARM middle-endian floats were a good idea). Unfortunately the articles I could find online discussing c++20 features mention integer types but not floats.

Did the standards committee overlook float and double types?
Please tell me no.

Also, the articles I could find seemed to suggest the additions will only provide a way to detect endianness, but not provide standard library functions for converting between different encodings. If that was the case, this doesn't seem any more useful than just standardizing a preprocessor definition.

Can someone knowledgeable about the upcoming c++20 proposals lay out what is (and is not) being included in the new endian features? (... and the 'why' would be awesome if you happen to know)

Does the c++20 endian proposal only deal with integer types, or does it also give information on float types?

As it stands, it'll tell you if all scalar types are big or little endian - or, the horror, they are not and you're dealing with mixed endianess.

All arithmetic types are included in scalars , both integer and floating point types.

The why: Pure speculation, but making a portable test when having seen gazillions of C type punning versions ported to C++ would be one why .

Also, the articles I could find seemed to suggest the additions will only provide a way to detect endianness, but not provide standard library functions for converting between different encodings. If that was the case, this doesn't seem any more useful than just standardizing a preprocessor definition.

You only get a portable way to detect endianess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM