C++ Logo

std-discussion

Advanced search

What even happened to <net> and byte swapping?

From: Matthew Woehlke <mwoehlke.floss_at_[hidden]>
Date: Fri, 19 Feb 2021 10:41:02 -0500
I was looking at some code that needs to do byte-order swapping, and it
seems the most portable way is still the non-standard htonX/ntohX family
of functions.

N3783 proposed standardizing these back in 2013(!)... but it doesn't
seem that this ever happened. We got std::endian (finally) in C++20, but
there do not seem to be any accompanying conversion functions.

Am I missing something, or do we still not have a way in standard C++ to
swap byte order of integer values?

-- 
Matthew

Received on 2021-02-19 09:41:05