Binary Serialize
Loading...
Searching...
No Matches
byteswap.hpp File Reference

This is an implementation of the C++ 23 std::byteswap function, for use in pre C++ 23 applications. More...

#include <concepts>
#include <bit>
#include <array>
#include <cstddef>
#include <algorithm>
Include dependency graph for byteswap.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<std::integral T>
constexpr T chops::byteswap (T value) noexcept
 Perform an in-place byte swap on an integral type (if size of the type is greater than one).
 

Detailed Description

This is an implementation of the C++ 23 std::byteswap function, for use in pre C++ 23 applications.

This implementation is taken directly from the CPP Reference page: https://en.cppreference.com/w/cpp/numeric/byteswap

Author
Cliff Green, CPP Reference

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Function Documentation

◆ byteswap()

template<std::integral T>
T chops::byteswap ( T value)
constexprnoexcept

Perform an in-place byte swap on an integral type (if size of the type is greater than one).

Template Parameters
TType of value where swapping will occur.
Parameters
valueIntegral value to be byte swapped.
Precondition
There must not be any padding bits in the type.