GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::endian(3) C++ Standard Libary std::endian(3)

std::endian - std::endian


Defined in header <bit>
enum class endian


{
little = /*implementation-defined*/, (since C++20)
big = /*implementation-defined*/,
native = /*implementation-defined*/


};


Indicates the endianness of all scalar types:


* If all scalar types are little-endian, std::endian::native equals
std::endian::little
* If all scalar types are big-endian, std::endian::native equals std::endian::big


Corner case platforms are also supported:


* If all scalar types have sizeof equal to 1, endianness does not matter and all
three values, std::endian::little, std::endian::big, and std::endian::native are
the same.
* If the platform uses mixed endian, std::endian::native equals neither
std::endian::big nor std::endian::little.


enum class endian
{
#ifdef _WIN32
little = 0,
big = 1,
native = little
#else
little = __ORDER_LITTLE_ENDIAN__,
big = __ORDER_BIG_ENDIAN__,
native = __BYTE_ORDER__
#endif
};


Feature-test macro: __cpp_lib_endian

// Run this code


#include <bit>
#include <iostream>


int main() {


if constexpr (std::endian::native == std::endian::big)
std::cout << "big-endian\n";
else if constexpr (std::endian::native == std::endian::little)
std::cout << "little-endian\n";
else std::cout << "mixed-endian\n";
}


little-endian


byteswap reverses the bytes in the given integer value
(C++23) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.