On Wed, 8 May 2013, Adrian_H wrote:
Andrey Semashev-2 wrote
When you care for endianness, you either program for a specific target (e.g. some low level code to speed up processing) or you're implementing some sort of binary (de)serialization. The first case is best covered with preprocessor macros, since target-specific code typically should not be compiled for other targets. The second case is what the C++ Standard is severely lacking, IMHO, but a third party library solution based on (non-portable) macros is still possible.
I think your first case is not really hugely relevant as the compiler is already fairly competent in that area.
I don't know, to do something as simple as extracting the exponent and mantissa of an IEEE float/double, using bitfields is significantly faster (and actually easier, since there is no standard function that does exactly that).
What we really need is a way to force the compiler to do a specific endianness of types and to set the padding/alignment of structures. Some type of modifier that when not used will allow the compiler to optimize as it sees fit, but if used, states that the type MUST BE this way, that the alignment MUST BE this way.
That could indeed be convenient when ease and compatibility are more important than speed, but it means you need to standardize very precisely the layout of classes in that mode, which is a significant amount of work. On Wed, 8 May 2013, Adrian_H wrote:
How does one write a proposal to the C++ committee?
http://isocpp.org/std/submit-a-proposal -- Marc Glisse