Remove C++03 workarounds

This commit is contained in:
Peter Dimov
2023-10-19 19:22:46 +03:00
parent 0e0a4fe51d
commit ccc8c3df3f
16 changed files with 493 additions and 556 deletions

View File

@ -27,13 +27,10 @@
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
#endif
#include <boost/endian/detail/requires_cxx11.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/endian/detail/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <cstdint>
#include <iosfwd>
#include <climits>
@ -45,17 +42,6 @@
# error Platforms with CHAR_BIT != 8 are not supported
# endif
# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
# else
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
# endif
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
# ifndef BOOST_ENDIAN_EXPLICIT_CTORS
# define BOOST_ENDIAN_EXPLICIT_OPT
# else
@ -69,33 +55,33 @@ namespace boost
namespace endian
{
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) Align = align::no>
template <order Order, class T, std::size_t n_bits,
align Align = align::no>
class endian_arithmetic;
// big endian signed integer aligned types
typedef endian_arithmetic<order::big, int8_t, 8, align::yes> big_int8_at;
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_at;
typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_at;
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_at;
typedef endian_arithmetic<order::big, std::int8_t, 8, align::yes> big_int8_at;
typedef endian_arithmetic<order::big, std::int16_t, 16, align::yes> big_int16_at;
typedef endian_arithmetic<order::big, std::int32_t, 32, align::yes> big_int32_at;
typedef endian_arithmetic<order::big, std::int64_t, 64, align::yes> big_int64_at;
// big endian unsigned integer aligned types
typedef endian_arithmetic<order::big, uint8_t, 8, align::yes> big_uint8_at;
typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_at;
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_at;
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_at;
typedef endian_arithmetic<order::big, std::uint8_t, 8, align::yes> big_uint8_at;
typedef endian_arithmetic<order::big, std::uint16_t, 16, align::yes> big_uint16_at;
typedef endian_arithmetic<order::big, std::uint32_t, 32, align::yes> big_uint32_at;
typedef endian_arithmetic<order::big, std::uint64_t, 64, align::yes> big_uint64_at;
// little endian signed integer aligned types
typedef endian_arithmetic<order::little, int8_t, 8, align::yes> little_int8_at;
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_at;
typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_at;
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_at;
typedef endian_arithmetic<order::little, std::int8_t, 8, align::yes> little_int8_at;
typedef endian_arithmetic<order::little, std::int16_t, 16, align::yes> little_int16_at;
typedef endian_arithmetic<order::little, std::int32_t, 32, align::yes> little_int32_at;
typedef endian_arithmetic<order::little, std::int64_t, 64, align::yes> little_int64_at;
// little endian unsigned integer aligned types
typedef endian_arithmetic<order::little, uint8_t, 8, align::yes> little_uint8_at;
typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_at;
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_at;
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_at;
typedef endian_arithmetic<order::little, std::uint8_t, 8, align::yes> little_uint8_at;
typedef endian_arithmetic<order::little, std::uint16_t, 16, align::yes> little_uint16_at;
typedef endian_arithmetic<order::little, std::uint32_t, 32, align::yes> little_uint32_at;
typedef endian_arithmetic<order::little, std::uint64_t, 64, align::yes> little_uint64_at;
// aligned floating point types
typedef endian_arithmetic<order::big, float, 32, align::yes> big_float32_at;
@ -107,64 +93,64 @@ namespace endian
// <cstdint> types are superior for this use case
// big endian signed integer unaligned types
typedef endian_arithmetic<order::big, int_least8_t, 8> big_int8_t;
typedef endian_arithmetic<order::big, int_least16_t, 16> big_int16_t;
typedef endian_arithmetic<order::big, int_least32_t, 24> big_int24_t;
typedef endian_arithmetic<order::big, int_least32_t, 32> big_int32_t;
typedef endian_arithmetic<order::big, int_least64_t, 40> big_int40_t;
typedef endian_arithmetic<order::big, int_least64_t, 48> big_int48_t;
typedef endian_arithmetic<order::big, int_least64_t, 56> big_int56_t;
typedef endian_arithmetic<order::big, int_least64_t, 64> big_int64_t;
typedef endian_arithmetic<order::big, std::int_least8_t, 8> big_int8_t;
typedef endian_arithmetic<order::big, std::int_least16_t, 16> big_int16_t;
typedef endian_arithmetic<order::big, std::int_least32_t, 24> big_int24_t;
typedef endian_arithmetic<order::big, std::int_least32_t, 32> big_int32_t;
typedef endian_arithmetic<order::big, std::int_least64_t, 40> big_int40_t;
typedef endian_arithmetic<order::big, std::int_least64_t, 48> big_int48_t;
typedef endian_arithmetic<order::big, std::int_least64_t, 56> big_int56_t;
typedef endian_arithmetic<order::big, std::int_least64_t, 64> big_int64_t;
// big endian unsigned integer unaligned types
typedef endian_arithmetic<order::big, uint_least8_t, 8> big_uint8_t;
typedef endian_arithmetic<order::big, uint_least16_t, 16> big_uint16_t;
typedef endian_arithmetic<order::big, uint_least32_t, 24> big_uint24_t;
typedef endian_arithmetic<order::big, uint_least32_t, 32> big_uint32_t;
typedef endian_arithmetic<order::big, uint_least64_t, 40> big_uint40_t;
typedef endian_arithmetic<order::big, uint_least64_t, 48> big_uint48_t;
typedef endian_arithmetic<order::big, uint_least64_t, 56> big_uint56_t;
typedef endian_arithmetic<order::big, uint_least64_t, 64> big_uint64_t;
typedef endian_arithmetic<order::big, std::uint_least8_t, 8> big_uint8_t;
typedef endian_arithmetic<order::big, std::uint_least16_t, 16> big_uint16_t;
typedef endian_arithmetic<order::big, std::uint_least32_t, 24> big_uint24_t;
typedef endian_arithmetic<order::big, std::uint_least32_t, 32> big_uint32_t;
typedef endian_arithmetic<order::big, std::uint_least64_t, 40> big_uint40_t;
typedef endian_arithmetic<order::big, std::uint_least64_t, 48> big_uint48_t;
typedef endian_arithmetic<order::big, std::uint_least64_t, 56> big_uint56_t;
typedef endian_arithmetic<order::big, std::uint_least64_t, 64> big_uint64_t;
// little endian signed integer unaligned types
typedef endian_arithmetic<order::little, int_least8_t, 8> little_int8_t;
typedef endian_arithmetic<order::little, int_least16_t, 16> little_int16_t;
typedef endian_arithmetic<order::little, int_least32_t, 24> little_int24_t;
typedef endian_arithmetic<order::little, int_least32_t, 32> little_int32_t;
typedef endian_arithmetic<order::little, int_least64_t, 40> little_int40_t;
typedef endian_arithmetic<order::little, int_least64_t, 48> little_int48_t;
typedef endian_arithmetic<order::little, int_least64_t, 56> little_int56_t;
typedef endian_arithmetic<order::little, int_least64_t, 64> little_int64_t;
typedef endian_arithmetic<order::little, std::int_least8_t, 8> little_int8_t;
typedef endian_arithmetic<order::little, std::int_least16_t, 16> little_int16_t;
typedef endian_arithmetic<order::little, std::int_least32_t, 24> little_int24_t;
typedef endian_arithmetic<order::little, std::int_least32_t, 32> little_int32_t;
typedef endian_arithmetic<order::little, std::int_least64_t, 40> little_int40_t;
typedef endian_arithmetic<order::little, std::int_least64_t, 48> little_int48_t;
typedef endian_arithmetic<order::little, std::int_least64_t, 56> little_int56_t;
typedef endian_arithmetic<order::little, std::int_least64_t, 64> little_int64_t;
// little endian unsigned integer unaligned types
typedef endian_arithmetic<order::little, uint_least8_t, 8> little_uint8_t;
typedef endian_arithmetic<order::little, uint_least16_t, 16> little_uint16_t;
typedef endian_arithmetic<order::little, uint_least32_t, 24> little_uint24_t;
typedef endian_arithmetic<order::little, uint_least32_t, 32> little_uint32_t;
typedef endian_arithmetic<order::little, uint_least64_t, 40> little_uint40_t;
typedef endian_arithmetic<order::little, uint_least64_t, 48> little_uint48_t;
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_t;
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_t;
typedef endian_arithmetic<order::little, std::uint_least8_t, 8> little_uint8_t;
typedef endian_arithmetic<order::little, std::uint_least16_t, 16> little_uint16_t;
typedef endian_arithmetic<order::little, std::uint_least32_t, 24> little_uint24_t;
typedef endian_arithmetic<order::little, std::uint_least32_t, 32> little_uint32_t;
typedef endian_arithmetic<order::little, std::uint_least64_t, 40> little_uint40_t;
typedef endian_arithmetic<order::little, std::uint_least64_t, 48> little_uint48_t;
typedef endian_arithmetic<order::little, std::uint_least64_t, 56> little_uint56_t;
typedef endian_arithmetic<order::little, std::uint_least64_t, 64> little_uint64_t;
// native endian signed integer unaligned types
typedef endian_arithmetic<order::native, int_least8_t, 8> native_int8_t;
typedef endian_arithmetic<order::native, int_least16_t, 16> native_int16_t;
typedef endian_arithmetic<order::native, int_least32_t, 24> native_int24_t;
typedef endian_arithmetic<order::native, int_least32_t, 32> native_int32_t;
typedef endian_arithmetic<order::native, int_least64_t, 40> native_int40_t;
typedef endian_arithmetic<order::native, int_least64_t, 48> native_int48_t;
typedef endian_arithmetic<order::native, int_least64_t, 56> native_int56_t;
typedef endian_arithmetic<order::native, int_least64_t, 64> native_int64_t;
typedef endian_arithmetic<order::native, std::int_least8_t, 8> native_int8_t;
typedef endian_arithmetic<order::native, std::int_least16_t, 16> native_int16_t;
typedef endian_arithmetic<order::native, std::int_least32_t, 24> native_int24_t;
typedef endian_arithmetic<order::native, std::int_least32_t, 32> native_int32_t;
typedef endian_arithmetic<order::native, std::int_least64_t, 40> native_int40_t;
typedef endian_arithmetic<order::native, std::int_least64_t, 48> native_int48_t;
typedef endian_arithmetic<order::native, std::int_least64_t, 56> native_int56_t;
typedef endian_arithmetic<order::native, std::int_least64_t, 64> native_int64_t;
// native endian unsigned integer unaligned types
typedef endian_arithmetic<order::native, uint_least8_t, 8> native_uint8_t;
typedef endian_arithmetic<order::native, uint_least16_t, 16> native_uint16_t;
typedef endian_arithmetic<order::native, uint_least32_t, 24> native_uint24_t;
typedef endian_arithmetic<order::native, uint_least32_t, 32> native_uint32_t;
typedef endian_arithmetic<order::native, uint_least64_t, 40> native_uint40_t;
typedef endian_arithmetic<order::native, uint_least64_t, 48> native_uint48_t;
typedef endian_arithmetic<order::native, uint_least64_t, 56> native_uint56_t;
typedef endian_arithmetic<order::native, uint_least64_t, 64> native_uint64_t;
typedef endian_arithmetic<order::native, std::uint_least8_t, 8> native_uint8_t;
typedef endian_arithmetic<order::native, std::uint_least16_t, 16> native_uint16_t;
typedef endian_arithmetic<order::native, std::uint_least32_t, 24> native_uint24_t;
typedef endian_arithmetic<order::native, std::uint_least32_t, 32> native_uint32_t;
typedef endian_arithmetic<order::native, std::uint_least64_t, 40> native_uint40_t;
typedef endian_arithmetic<order::native, std::uint_least64_t, 48> native_uint48_t;
typedef endian_arithmetic<order::native, std::uint_least64_t, 56> native_uint56_t;
typedef endian_arithmetic<order::native, std::uint_least64_t, 64> native_uint64_t;
// unaligned floating point types
typedef endian_arithmetic<order::big, float, 32, align::no> big_float32_t;
@ -176,8 +162,8 @@ namespace endian
//---------------------------------- end synopsis ------------------------------------//
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) Align>
template <order Order, class T, std::size_t n_bits,
align Align>
class endian_arithmetic
{
private:
@ -198,7 +184,7 @@ public:
#ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
endian_arithmetic() = default;
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic( T val ) BOOST_NOEXCEPT: buf_( val )
{

View File

@ -27,14 +27,11 @@
# pragma warning(disable: 4127) // conditional expression is constant
#endif
#include <boost/endian/detail/requires_cxx11.hpp>
#include <boost/endian/detail/endian_store.hpp>
#include <boost/endian/detail/endian_load.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/endian/detail/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <cstdint>
#include <iosfwd>
#include <climits>
#include <cstring>
@ -47,17 +44,6 @@
# error Platforms with CHAR_BIT != 8 are not supported
# endif
# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
# else
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
# endif
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
//---------------------------------- synopsis ----------------------------------------//
namespace boost
@ -65,40 +51,40 @@ namespace boost
namespace endian
{
BOOST_SCOPED_ENUM_START(align)
enum class align
{no, yes
# ifdef BOOST_ENDIAN_DEPRECATED_NAMES
, unaligned = no, aligned = yes
# endif
}; BOOST_SCOPED_ENUM_END
};
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) A = align::no>
template <order Order, class T, std::size_t n_bits,
align A = align::no>
class endian_buffer;
// aligned big endian signed integer buffers
typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_at;
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_at;
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_at;
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_at;
typedef endian_buffer<order::big, std::int8_t, 8, align::yes> big_int8_buf_at;
typedef endian_buffer<order::big, std::int16_t, 16, align::yes> big_int16_buf_at;
typedef endian_buffer<order::big, std::int32_t, 32, align::yes> big_int32_buf_at;
typedef endian_buffer<order::big, std::int64_t, 64, align::yes> big_int64_buf_at;
// aligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint8_t, 8, align::yes> big_uint8_buf_at;
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_at;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_at;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_at;
typedef endian_buffer<order::big, std::uint8_t, 8, align::yes> big_uint8_buf_at;
typedef endian_buffer<order::big, std::uint16_t, 16, align::yes> big_uint16_buf_at;
typedef endian_buffer<order::big, std::uint32_t, 32, align::yes> big_uint32_buf_at;
typedef endian_buffer<order::big, std::uint64_t, 64, align::yes> big_uint64_buf_at;
// aligned little endian signed integer buffers
typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_at;
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_at;
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_at;
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_at;
typedef endian_buffer<order::little, std::int8_t, 8, align::yes> little_int8_buf_at;
typedef endian_buffer<order::little, std::int16_t, 16, align::yes> little_int16_buf_at;
typedef endian_buffer<order::little, std::int32_t, 32, align::yes> little_int32_buf_at;
typedef endian_buffer<order::little, std::int64_t, 64, align::yes> little_int64_buf_at;
// aligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint8_t, 8, align::yes> little_uint8_buf_at;
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_at;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_at;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_at;
typedef endian_buffer<order::little, std::uint8_t, 8, align::yes> little_uint8_buf_at;
typedef endian_buffer<order::little, std::uint16_t, 16, align::yes> little_uint16_buf_at;
typedef endian_buffer<order::little, std::uint32_t, 32, align::yes> little_uint32_buf_at;
typedef endian_buffer<order::little, std::uint64_t, 64, align::yes> little_uint64_buf_at;
// aligned floating point buffers
typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_at;
@ -110,64 +96,64 @@ namespace endian
// <cstdint> types are superior for this use case
// unaligned big endian signed integer buffers
typedef endian_buffer<order::big, int_least8_t, 8> big_int8_buf_t;
typedef endian_buffer<order::big, int_least16_t, 16> big_int16_buf_t;
typedef endian_buffer<order::big, int_least32_t, 24> big_int24_buf_t;
typedef endian_buffer<order::big, int_least32_t, 32> big_int32_buf_t;
typedef endian_buffer<order::big, int_least64_t, 40> big_int40_buf_t;
typedef endian_buffer<order::big, int_least64_t, 48> big_int48_buf_t;
typedef endian_buffer<order::big, int_least64_t, 56> big_int56_buf_t;
typedef endian_buffer<order::big, int_least64_t, 64> big_int64_buf_t;
typedef endian_buffer<order::big, std::int_least8_t, 8> big_int8_buf_t;
typedef endian_buffer<order::big, std::int_least16_t, 16> big_int16_buf_t;
typedef endian_buffer<order::big, std::int_least32_t, 24> big_int24_buf_t;
typedef endian_buffer<order::big, std::int_least32_t, 32> big_int32_buf_t;
typedef endian_buffer<order::big, std::int_least64_t, 40> big_int40_buf_t;
typedef endian_buffer<order::big, std::int_least64_t, 48> big_int48_buf_t;
typedef endian_buffer<order::big, std::int_least64_t, 56> big_int56_buf_t;
typedef endian_buffer<order::big, std::int_least64_t, 64> big_int64_buf_t;
// unaligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint_least8_t, 8> big_uint8_buf_t;
typedef endian_buffer<order::big, uint_least16_t, 16> big_uint16_buf_t;
typedef endian_buffer<order::big, uint_least32_t, 24> big_uint24_buf_t;
typedef endian_buffer<order::big, uint_least32_t, 32> big_uint32_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 40> big_uint40_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 48> big_uint48_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_t;
typedef endian_buffer<order::big, std::uint_least8_t, 8> big_uint8_buf_t;
typedef endian_buffer<order::big, std::uint_least16_t, 16> big_uint16_buf_t;
typedef endian_buffer<order::big, std::uint_least32_t, 24> big_uint24_buf_t;
typedef endian_buffer<order::big, std::uint_least32_t, 32> big_uint32_buf_t;
typedef endian_buffer<order::big, std::uint_least64_t, 40> big_uint40_buf_t;
typedef endian_buffer<order::big, std::uint_least64_t, 48> big_uint48_buf_t;
typedef endian_buffer<order::big, std::uint_least64_t, 56> big_uint56_buf_t;
typedef endian_buffer<order::big, std::uint_least64_t, 64> big_uint64_buf_t;
// unaligned little endian signed integer buffers
typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_t;
typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_t;
typedef endian_buffer<order::little, int_least32_t, 24> little_int24_buf_t;
typedef endian_buffer<order::little, int_least32_t, 32> little_int32_buf_t;
typedef endian_buffer<order::little, int_least64_t, 40> little_int40_buf_t;
typedef endian_buffer<order::little, int_least64_t, 48> little_int48_buf_t;
typedef endian_buffer<order::little, int_least64_t, 56> little_int56_buf_t;
typedef endian_buffer<order::little, int_least64_t, 64> little_int64_buf_t;
typedef endian_buffer<order::little, std::int_least8_t, 8> little_int8_buf_t;
typedef endian_buffer<order::little, std::int_least16_t, 16> little_int16_buf_t;
typedef endian_buffer<order::little, std::int_least32_t, 24> little_int24_buf_t;
typedef endian_buffer<order::little, std::int_least32_t, 32> little_int32_buf_t;
typedef endian_buffer<order::little, std::int_least64_t, 40> little_int40_buf_t;
typedef endian_buffer<order::little, std::int_least64_t, 48> little_int48_buf_t;
typedef endian_buffer<order::little, std::int_least64_t, 56> little_int56_buf_t;
typedef endian_buffer<order::little, std::int_least64_t, 64> little_int64_buf_t;
// unaligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint_least8_t, 8> little_uint8_buf_t;
typedef endian_buffer<order::little, uint_least16_t, 16> little_uint16_buf_t;
typedef endian_buffer<order::little, uint_least32_t, 24> little_uint24_buf_t;
typedef endian_buffer<order::little, uint_least32_t, 32> little_uint32_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 40> little_uint40_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 48> little_uint48_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t;
typedef endian_buffer<order::little, std::uint_least8_t, 8> little_uint8_buf_t;
typedef endian_buffer<order::little, std::uint_least16_t, 16> little_uint16_buf_t;
typedef endian_buffer<order::little, std::uint_least32_t, 24> little_uint24_buf_t;
typedef endian_buffer<order::little, std::uint_least32_t, 32> little_uint32_buf_t;
typedef endian_buffer<order::little, std::uint_least64_t, 40> little_uint40_buf_t;
typedef endian_buffer<order::little, std::uint_least64_t, 48> little_uint48_buf_t;
typedef endian_buffer<order::little, std::uint_least64_t, 56> little_uint56_buf_t;
typedef endian_buffer<order::little, std::uint_least64_t, 64> little_uint64_buf_t;
// unaligned native endian signed integer buffers
typedef endian_buffer<order::native, int_least8_t, 8> native_int8_buf_t;
typedef endian_buffer<order::native, int_least16_t, 16> native_int16_buf_t;
typedef endian_buffer<order::native, int_least32_t, 24> native_int24_buf_t;
typedef endian_buffer<order::native, int_least32_t, 32> native_int32_buf_t;
typedef endian_buffer<order::native, int_least64_t, 40> native_int40_buf_t;
typedef endian_buffer<order::native, int_least64_t, 48> native_int48_buf_t;
typedef endian_buffer<order::native, int_least64_t, 56> native_int56_buf_t;
typedef endian_buffer<order::native, int_least64_t, 64> native_int64_buf_t;
typedef endian_buffer<order::native, std::int_least8_t, 8> native_int8_buf_t;
typedef endian_buffer<order::native, std::int_least16_t, 16> native_int16_buf_t;
typedef endian_buffer<order::native, std::int_least32_t, 24> native_int24_buf_t;
typedef endian_buffer<order::native, std::int_least32_t, 32> native_int32_buf_t;
typedef endian_buffer<order::native, std::int_least64_t, 40> native_int40_buf_t;
typedef endian_buffer<order::native, std::int_least64_t, 48> native_int48_buf_t;
typedef endian_buffer<order::native, std::int_least64_t, 56> native_int56_buf_t;
typedef endian_buffer<order::native, std::int_least64_t, 64> native_int64_buf_t;
// unaligned native endian unsigned integer buffers
typedef endian_buffer<order::native, uint_least8_t, 8> native_uint8_buf_t;
typedef endian_buffer<order::native, uint_least16_t, 16> native_uint16_buf_t;
typedef endian_buffer<order::native, uint_least32_t, 24> native_uint24_buf_t;
typedef endian_buffer<order::native, uint_least32_t, 32> native_uint32_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 40> native_uint40_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 48> native_uint48_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 56> native_uint56_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 64> native_uint64_buf_t;
typedef endian_buffer<order::native, std::uint_least8_t, 8> native_uint8_buf_t;
typedef endian_buffer<order::native, std::uint_least16_t, 16> native_uint16_buf_t;
typedef endian_buffer<order::native, std::uint_least32_t, 24> native_uint24_buf_t;
typedef endian_buffer<order::native, std::uint_least32_t, 32> native_uint32_buf_t;
typedef endian_buffer<order::native, std::uint_least64_t, 40> native_uint40_buf_t;
typedef endian_buffer<order::native, std::uint_least64_t, 48> native_uint48_buf_t;
typedef endian_buffer<order::native, std::uint_least64_t, 56> native_uint56_buf_t;
typedef endian_buffer<order::native, std::uint_least64_t, 64> native_uint64_buf_t;
// unaligned floating point buffers
typedef endian_buffer<order::big, float, 32, align::no> big_float32_buf_t;
@ -178,8 +164,8 @@ namespace endian
typedef endian_buffer<order::native, double, 64, align::no> native_float64_buf_t;
// Stream inserter
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
template <class charT, class traits, order Order, class T,
std::size_t n_bits, align A>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const endian_buffer<Order, T, n_bits, A>& x)
@ -188,8 +174,8 @@ namespace endian
}
// Stream extractor
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
template <class charT, class traits, order Order, class T,
std::size_t n_bits, align A>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is,
endian_buffer<Order, T, n_bits, A>& x)
@ -216,14 +202,14 @@ namespace endian
// unaligned endian_buffer specialization
template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits >
template< order Order, class T, std::size_t n_bits >
class endian_buffer<Order, T, n_bits, align::no>
{
#ifdef BOOST_ENDIAN_NO_CTORS
public:
#endif
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
unsigned char value_[ n_bits / 8 ];
@ -233,7 +219,7 @@ public:
#ifndef BOOST_ENDIAN_NO_CTORS
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
endian_buffer() = default;
explicit endian_buffer( T val ) BOOST_NOEXCEPT
{
@ -268,13 +254,13 @@ public:
// aligned endian_buffer specialization
template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits >
template< order Order, class T, std::size_t n_bits >
class endian_buffer<Order, T, n_bits, align::yes>
{
private:
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == n_bits/8 );
union
{
@ -288,7 +274,7 @@ public:
#ifndef BOOST_ENDIAN_NO_CTORS
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
endian_buffer() = default;
explicit endian_buffer( T val ) BOOST_NOEXCEPT
{
@ -326,8 +312,8 @@ class endian_buffer<order::native, T, n_bits, align::yes>
{
private:
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
BOOST_ENDIAN_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == n_bits/8 );
T value_;
@ -337,7 +323,7 @@ public:
#ifndef BOOST_ENDIAN_NO_CTORS
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
endian_buffer() = default;
explicit endian_buffer( T val ) BOOST_NOEXCEPT: value_( val )
{

View File

@ -8,17 +8,14 @@
#ifndef BOOST_ENDIAN_CONVERSION_HPP
#define BOOST_ENDIAN_CONVERSION_HPP
#include <boost/endian/detail/requires_cxx11.hpp>
#include <boost/endian/detail/endian_reverse.hpp>
#include <boost/endian/detail/endian_load.hpp>
#include <boost/endian/detail/endian_store.hpp>
#include <boost/endian/detail/order.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/endian/detail/static_assert.hpp>
#include <boost/config.hpp>
#include <type_traits>
#include <cstdint>
//------------------------------------- synopsis ---------------------------------------//
@ -66,7 +63,7 @@ namespace endian
// Returns: x if native endian order is little, otherwise endian_reverse(x)
// generic conditional reverse byte order
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
template <order From, order To,
class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT;
// Returns: If From == To have different values, from.
@ -77,7 +74,7 @@ namespace endian
// runtime conditional reverse byte order
template <class EndianReversible >
inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
order from_order, order to_order)
BOOST_NOEXCEPT;
// Returns: from_order == to_order ? from : endian_reverse(from).
@ -133,14 +130,14 @@ namespace endian
// Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
// generic conditional reverse in place
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
template <order From, order To,
class EndianReversibleInplace>
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
// runtime reverse in place
template <class EndianReversibleInplace>
inline void conditional_reverse_inplace(EndianReversibleInplace& x,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
order from_order, order to_order)
BOOST_NOEXCEPT;
//----------------------------------- end synopsis -------------------------------------//
@ -173,13 +170,13 @@ namespace detail
{
template<class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::true_type ) BOOST_NOEXCEPT
{
return x;
}
template<class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, std::false_type ) BOOST_NOEXCEPT
{
return endian_reverse( x );
}
@ -187,19 +184,19 @@ inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversib
} // namespace detail
// generic conditional reverse
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
template <order From, order To, class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
BOOST_ENDIAN_STATIC_ASSERT( std::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
return detail::conditional_reverse_impl( x, std::integral_constant<bool, From == To>() );
}
// runtime conditional reverse
template <class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
order from_order, order to_order ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
return from_order == to_order? x: endian_reverse( x );
}
@ -235,12 +232,12 @@ namespace detail
{
template<class EndianReversibleInplace>
inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT
inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, std::true_type ) BOOST_NOEXCEPT
{
}
template<class EndianReversibleInplace>
inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT
inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, std::false_type ) BOOST_NOEXCEPT
{
endian_reverse_inplace( x );
}
@ -248,25 +245,25 @@ inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost:
} // namespace detail
// generic conditional reverse in place
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
template <order From, order To, class EndianReversibleInplace>
inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT(
boost::is_class<EndianReversibleInplace>::value ||
boost::is_array<EndianReversibleInplace>::value ||
BOOST_ENDIAN_STATIC_ASSERT(
std::is_class<EndianReversibleInplace>::value ||
std::is_array<EndianReversibleInplace>::value ||
detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
detail::conditional_reverse_inplace_impl( x, std::integral_constant<bool, From == To>() );
}
// runtime reverse in place
template <class EndianReversibleInplace>
inline void conditional_reverse_inplace( EndianReversibleInplace& x,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
order from_order, order to_order ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT(
boost::is_class<EndianReversibleInplace>::value ||
boost::is_array<EndianReversibleInplace>::value ||
BOOST_ENDIAN_STATIC_ASSERT(
std::is_class<EndianReversibleInplace>::value ||
std::is_array<EndianReversibleInplace>::value ||
detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
if( from_order != to_order )
@ -279,310 +276,310 @@ inline void conditional_reverse_inplace( EndianReversibleInplace& x,
// load 16
inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int16_t, 2, order::little>( p );
return boost::endian::endian_load<std::int16_t, 2, order::little>( p );
}
inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint16_t, 2, order::little>( p );
return boost::endian::endian_load<std::uint16_t, 2, order::little>( p );
}
inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int16_t, 2, order::big>( p );
return boost::endian::endian_load<std::int16_t, 2, order::big>( p );
}
inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint16_t, 2, order::big>( p );
return boost::endian::endian_load<std::uint16_t, 2, order::big>( p );
}
// load 24
inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 3, order::little>( p );
return boost::endian::endian_load<std::int32_t, 3, order::little>( p );
}
inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 3, order::little>( p );
return boost::endian::endian_load<std::uint32_t, 3, order::little>( p );
}
inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 3, order::big>( p );
return boost::endian::endian_load<std::int32_t, 3, order::big>( p );
}
inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 3, order::big>( p );
return boost::endian::endian_load<std::uint32_t, 3, order::big>( p );
}
// load 32
inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 4, order::little>( p );
return boost::endian::endian_load<std::int32_t, 4, order::little>( p );
}
inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 4, order::little>( p );
return boost::endian::endian_load<std::uint32_t, 4, order::little>( p );
}
inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 4, order::big>( p );
return boost::endian::endian_load<std::int32_t, 4, order::big>( p );
}
inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 4, order::big>( p );
return boost::endian::endian_load<std::uint32_t, 4, order::big>( p );
}
// load 40
inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 5, order::little>( p );
return boost::endian::endian_load<std::int64_t, 5, order::little>( p );
}
inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 5, order::little>( p );
return boost::endian::endian_load<std::uint64_t, 5, order::little>( p );
}
inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 5, order::big>( p );
return boost::endian::endian_load<std::int64_t, 5, order::big>( p );
}
inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 5, order::big>( p );
return boost::endian::endian_load<std::uint64_t, 5, order::big>( p );
}
// load 48
inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 6, order::little>( p );
return boost::endian::endian_load<std::int64_t, 6, order::little>( p );
}
inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 6, order::little>( p );
return boost::endian::endian_load<std::uint64_t, 6, order::little>( p );
}
inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 6, order::big>( p );
return boost::endian::endian_load<std::int64_t, 6, order::big>( p );
}
inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 6, order::big>( p );
return boost::endian::endian_load<std::uint64_t, 6, order::big>( p );
}
// load 56
inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 7, order::little>( p );
return boost::endian::endian_load<std::int64_t, 7, order::little>( p );
}
inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 7, order::little>( p );
return boost::endian::endian_load<std::uint64_t, 7, order::little>( p );
}
inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 7, order::big>( p );
return boost::endian::endian_load<std::int64_t, 7, order::big>( p );
}
inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 7, order::big>( p );
return boost::endian::endian_load<std::uint64_t, 7, order::big>( p );
}
// load 64
inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 8, order::little>( p );
return boost::endian::endian_load<std::int64_t, 8, order::little>( p );
}
inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 8, order::little>( p );
return boost::endian::endian_load<std::uint64_t, 8, order::little>( p );
}
inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
inline std::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 8, order::big>( p );
return boost::endian::endian_load<std::int64_t, 8, order::big>( p );
}
inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
inline std::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 8, order::big>( p );
return boost::endian::endian_load<std::uint64_t, 8, order::big>( p );
}
// store 16
inline void store_little_s16( unsigned char * p, boost::int16_t v )
inline void store_little_s16( unsigned char * p, std::int16_t v )
{
boost::endian::endian_store<boost::int16_t, 2, order::little>( p, v );
boost::endian::endian_store<std::int16_t, 2, order::little>( p, v );
}
inline void store_little_u16( unsigned char * p, boost::uint16_t v )
inline void store_little_u16( unsigned char * p, std::uint16_t v )
{
boost::endian::endian_store<boost::uint16_t, 2, order::little>( p, v );
boost::endian::endian_store<std::uint16_t, 2, order::little>( p, v );
}
inline void store_big_s16( unsigned char * p, boost::int16_t v )
inline void store_big_s16( unsigned char * p, std::int16_t v )
{
boost::endian::endian_store<boost::int16_t, 2, order::big>( p, v );
boost::endian::endian_store<std::int16_t, 2, order::big>( p, v );
}
inline void store_big_u16( unsigned char * p, boost::uint16_t v )
inline void store_big_u16( unsigned char * p, std::uint16_t v )
{
boost::endian::endian_store<boost::uint16_t, 2, order::big>( p, v );
boost::endian::endian_store<std::uint16_t, 2, order::big>( p, v );
}
// store 24
inline void store_little_s24( unsigned char * p, boost::int32_t v )
inline void store_little_s24( unsigned char * p, std::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 3, order::little>( p, v );
boost::endian::endian_store<std::int32_t, 3, order::little>( p, v );
}
inline void store_little_u24( unsigned char * p, boost::uint32_t v )
inline void store_little_u24( unsigned char * p, std::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 3, order::little>( p, v );
boost::endian::endian_store<std::uint32_t, 3, order::little>( p, v );
}
inline void store_big_s24( unsigned char * p, boost::int32_t v )
inline void store_big_s24( unsigned char * p, std::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 3, order::big>( p, v );
boost::endian::endian_store<std::int32_t, 3, order::big>( p, v );
}
inline void store_big_u24( unsigned char * p, boost::uint32_t v )
inline void store_big_u24( unsigned char * p, std::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 3, order::big>( p, v );
boost::endian::endian_store<std::uint32_t, 3, order::big>( p, v );
}
// store 32
inline void store_little_s32( unsigned char * p, boost::int32_t v )
inline void store_little_s32( unsigned char * p, std::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 4, order::little>( p, v );
boost::endian::endian_store<std::int32_t, 4, order::little>( p, v );
}
inline void store_little_u32( unsigned char * p, boost::uint32_t v )
inline void store_little_u32( unsigned char * p, std::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 4, order::little>( p, v );
boost::endian::endian_store<std::uint32_t, 4, order::little>( p, v );
}
inline void store_big_s32( unsigned char * p, boost::int32_t v )
inline void store_big_s32( unsigned char * p, std::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 4, order::big>( p, v );
boost::endian::endian_store<std::int32_t, 4, order::big>( p, v );
}
inline void store_big_u32( unsigned char * p, boost::uint32_t v )
inline void store_big_u32( unsigned char * p, std::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 4, order::big>( p, v );
boost::endian::endian_store<std::uint32_t, 4, order::big>( p, v );
}
// store 40
inline void store_little_s40( unsigned char * p, boost::int64_t v )
inline void store_little_s40( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 5, order::little>( p, v );
boost::endian::endian_store<std::int64_t, 5, order::little>( p, v );
}
inline void store_little_u40( unsigned char * p, boost::uint64_t v )
inline void store_little_u40( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 5, order::little>( p, v );
boost::endian::endian_store<std::uint64_t, 5, order::little>( p, v );
}
inline void store_big_s40( unsigned char * p, boost::int64_t v )
inline void store_big_s40( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 5, order::big>( p, v );
boost::endian::endian_store<std::int64_t, 5, order::big>( p, v );
}
inline void store_big_u40( unsigned char * p, boost::uint64_t v )
inline void store_big_u40( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 5, order::big>( p, v );
boost::endian::endian_store<std::uint64_t, 5, order::big>( p, v );
}
// store 48
inline void store_little_s48( unsigned char * p, boost::int64_t v )
inline void store_little_s48( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 6, order::little>( p, v );
boost::endian::endian_store<std::int64_t, 6, order::little>( p, v );
}
inline void store_little_u48( unsigned char * p, boost::uint64_t v )
inline void store_little_u48( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 6, order::little>( p, v );
boost::endian::endian_store<std::uint64_t, 6, order::little>( p, v );
}
inline void store_big_s48( unsigned char * p, boost::int64_t v )
inline void store_big_s48( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 6, order::big>( p, v );
boost::endian::endian_store<std::int64_t, 6, order::big>( p, v );
}
inline void store_big_u48( unsigned char * p, boost::uint64_t v )
inline void store_big_u48( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 6, order::big>( p, v );
boost::endian::endian_store<std::uint64_t, 6, order::big>( p, v );
}
// store 56
inline void store_little_s56( unsigned char * p, boost::int64_t v )
inline void store_little_s56( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 7, order::little>( p, v );
boost::endian::endian_store<std::int64_t, 7, order::little>( p, v );
}
inline void store_little_u56( unsigned char * p, boost::uint64_t v )
inline void store_little_u56( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 7, order::little>( p, v );
boost::endian::endian_store<std::uint64_t, 7, order::little>( p, v );
}
inline void store_big_s56( unsigned char * p, boost::int64_t v )
inline void store_big_s56( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 7, order::big>( p, v );
boost::endian::endian_store<std::int64_t, 7, order::big>( p, v );
}
inline void store_big_u56( unsigned char * p, boost::uint64_t v )
inline void store_big_u56( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 7, order::big>( p, v );
boost::endian::endian_store<std::uint64_t, 7, order::big>( p, v );
}
// store 64
inline void store_little_s64( unsigned char * p, boost::int64_t v )
inline void store_little_s64( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 8, order::little>( p, v );
boost::endian::endian_store<std::int64_t, 8, order::little>( p, v );
}
inline void store_little_u64( unsigned char * p, boost::uint64_t v )
inline void store_little_u64( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 8, order::little>( p, v );
boost::endian::endian_store<std::uint64_t, 8, order::little>( p, v );
}
inline void store_big_s64( unsigned char * p, boost::int64_t v )
inline void store_big_s64( unsigned char * p, std::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 8, order::big>( p, v );
boost::endian::endian_store<std::int64_t, 8, order::big>( p, v );
}
inline void store_big_u64( unsigned char * p, boost::uint64_t v )
inline void store_big_u64( unsigned char * p, std::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 8, order::big>( p, v );
boost::endian::endian_store<std::uint64_t, 8, order::big>( p, v );
}
} // namespace endian

View File

@ -10,10 +10,8 @@
#include <boost/endian/detail/order.hpp>
#include <boost/endian/detail/integral_by_size.hpp>
#include <boost/endian/detail/is_trivially_copyable.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/static_assert.hpp>
#include <boost/endian/detail/static_assert.hpp>
#include <type_traits>
#include <cstddef>
#include <cstring>
@ -25,7 +23,7 @@ namespace endian
namespace detail
{
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl
template<class T, std::size_t N1, order O1, std::size_t N2, order O2> struct endian_load_impl
{
};
@ -38,11 +36,11 @@ template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, B
// T is TriviallyCopyable
// if N < sizeof(T), T is integral or enum
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
template<class T, std::size_t N, order Order>
inline T endian_load( unsigned char const * p ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
BOOST_ENDIAN_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
return detail::endian_load_impl<T, sizeof(T), order::native, N, Order>()( p );
}
@ -52,11 +50,11 @@ namespace detail
// same endianness, same size
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_load_impl<T, N, O, N, O>
template<class T, std::size_t N, order O> struct endian_load_impl<T, N, O, N, O>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
T t;
std::memcpy( &t, p, N );
@ -66,11 +64,11 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_load_
// same size, reverse endianness
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl<T, N, O1, N, O2>
template<class T, std::size_t N, order O1, order O2> struct endian_load_impl<T, N, O1, N, O2>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
typename integral_by_size<N>::type tmp;
std::memcpy( &tmp, p, N );
@ -85,30 +83,30 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(
// expanding load 1 -> 2
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::little>
template<class T, order Order> struct endian_load_impl<T, 2, Order, 1, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 2 ];
tmp[0] = p[0];
tmp[1] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[1] = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
return boost::endian::endian_load<T, 2, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::big>
template<class T, order Order> struct endian_load_impl<T, 2, Order, 1, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 2 ];
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[1] = p[0];
return boost::endian::endian_load<T, 2, order::big>( tmp );
@ -117,15 +115,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2,
// expanding load 1 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::little>
template<class T, order Order> struct endian_load_impl<T, 4, Order, 1, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = fill;
@ -136,15 +134,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::big>
template<class T, order Order> struct endian_load_impl<T, 4, Order, 1, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -157,15 +155,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
// expanding load 2 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::little>
template<class T, order Order> struct endian_load_impl<T, 4, Order, 2, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -176,15 +174,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::big>
template<class T, order Order> struct endian_load_impl<T, 4, Order, 2, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -197,32 +195,32 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
// expanding load 3 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::little>
template<class T, order Order> struct endian_load_impl<T, 4, Order, 3, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
tmp[3] = std::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
return boost::endian::endian_load<T, 4, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::big>
template<class T, order Order> struct endian_load_impl<T, 4, Order, 3, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[1] = p[0];
tmp[2] = p[1];
tmp[3] = p[2];
@ -233,15 +231,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4,
// expanding load 1 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 1, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
@ -257,15 +255,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 1, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -283,15 +281,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
// expanding load 2 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 2, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -307,15 +305,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 2, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -333,15 +331,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
// expanding load 3 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 3, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -357,15 +355,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 3, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -383,15 +381,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
// expanding load 4 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 4, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[3] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[3] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -407,15 +405,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 4, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -433,15 +431,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
// expanding load 5 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 5, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[4] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[4] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -457,15 +455,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 5, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -483,15 +481,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
// expanding load 6 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 6, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[5] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[5] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -507,15 +505,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 6, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
@ -533,15 +531,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
// expanding load 7 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::little>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 7, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[6] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[6] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
@ -557,15 +555,15 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::big>
template<class T, order Order> struct endian_load_impl<T, 8, Order, 7, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
unsigned char fill = std::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;

View File

@ -8,14 +8,10 @@
#include <boost/endian/detail/integral_by_size.hpp>
#include <boost/endian/detail/intrinsic.hpp>
#include <boost/endian/detail/is_scoped_enum.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/endian/detail/static_assert.hpp>
#include <boost/config.hpp>
#include <type_traits>
#include <cstdint>
#include <cstddef>
#include <cstring>
@ -47,12 +43,12 @@ namespace detail
// -- intrinsic approach suggested by reviewers, and by David Stone, who provided
// his Boost licensed macro implementation (detail/intrinsic.hpp)
inline uint8_t BOOST_CONSTEXPR endian_reverse_impl( uint8_t x ) BOOST_NOEXCEPT
inline std::uint8_t BOOST_CONSTEXPR endian_reverse_impl( std::uint8_t x ) BOOST_NOEXCEPT
{
return x;
}
inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_NOEXCEPT
inline std::uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint16_t x ) BOOST_NOEXCEPT
{
#ifdef BOOST_ENDIAN_NO_INTRINSICS
@ -65,11 +61,11 @@ inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_N
#endif
}
inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_NOEXCEPT
inline std::uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint32_t x ) BOOST_NOEXCEPT
{
#ifdef BOOST_ENDIAN_NO_INTRINSICS
uint32_t step16 = x << 16 | x >> 16;
std::uint32_t step16 = x << 16 | x >> 16;
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
#else
@ -79,12 +75,12 @@ inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_N
#endif
}
inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_NOEXCEPT
inline std::uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( std::uint64_t x ) BOOST_NOEXCEPT
{
#ifdef BOOST_ENDIAN_NO_INTRINSICS
uint64_t step32 = x << 32 | x >> 32;
uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
std::uint64_t step32 = x << 32 | x >> 32;
std::uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8;
#else
@ -94,27 +90,27 @@ inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_N
# endif
}
#if defined(BOOST_HAS_INT128)
#if defined(__SIZEOF_INT128__)
inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x ) BOOST_NOEXCEPT
inline __uint128_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( __uint128_t x ) BOOST_NOEXCEPT
{
return endian_reverse_impl( static_cast<uint64_t>( x >> 64 ) ) |
static_cast<uint128_type>( endian_reverse_impl( static_cast<uint64_t>( x ) ) ) << 64;
return endian_reverse_impl( static_cast<std::uint64_t>( x >> 64 ) ) |
static_cast<__uint128_t>( endian_reverse_impl( static_cast<std::uint64_t>( x ) ) ) << 64;
}
#endif
// is_endian_reversible
template<class T> struct is_endian_reversible: boost::integral_constant<bool,
(boost::is_integral<T>::value && !boost::is_same<T, bool>::value) || is_scoped_enum<T>::value>
template<class T> struct is_endian_reversible: std::integral_constant<bool,
(std::is_integral<T>::value && !std::is_same<T, bool>::value) || is_scoped_enum<T>::value>
{
};
// is_endian_reversible_inplace
template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
boost::is_integral<T>::value || boost::is_enum<T>::value || boost::is_same<T, float>::value || boost::is_same<T, double>::value>
template<class T> struct is_endian_reversible_inplace: std::integral_constant<bool,
std::is_integral<T>::value || std::is_enum<T>::value || std::is_same<T, float>::value || std::is_same<T, double>::value>
{
};
@ -124,10 +120,10 @@ template<class T> struct is_endian_reversible_inplace: boost::integral_constant<
// T is non-bool integral or scoped enumeration type
template<class T> inline BOOST_CONSTEXPR
typename enable_if_< !is_class<T>::value, T >::type
typename std::enable_if< !std::is_class<T>::value, T >::type
endian_reverse( T x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t;
@ -138,10 +134,10 @@ template<class T> inline BOOST_CONSTEXPR
// T is integral, enumeration, float or double
template<class T> inline
typename enable_if_< !is_class<T>::value >::type
typename std::enable_if< !std::is_class<T>::value >::type
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( detail::is_endian_reversible_inplace<T>::value );
typename detail::integral_by_size< sizeof(T) >::type x2;
@ -155,7 +151,7 @@ template<class T> inline
// Default implementation for user-defined types
template<class T> inline
typename enable_if_< is_class<T>::value >::type
typename std::enable_if< std::is_class<T>::value >::type
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
{
x = endian_reverse( x );

View File

@ -10,9 +10,8 @@
#include <boost/endian/detail/order.hpp>
#include <boost/endian/detail/integral_by_size.hpp>
#include <boost/endian/detail/is_trivially_copyable.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/static_assert.hpp>
#include <boost/endian/detail/static_assert.hpp>
#include <type_traits>
#include <cstddef>
#include <cstring>
@ -24,7 +23,7 @@ namespace endian
namespace detail
{
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl
template<class T, std::size_t N1, order O1, std::size_t N2, order O2> struct endian_store_impl
{
};
@ -37,11 +36,11 @@ template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, B
// T is TriviallyCopyable
// if N < sizeof(T), T is integral or enum
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
template<class T, std::size_t N, order Order>
inline void endian_store( unsigned char * p, T const & v ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
BOOST_ENDIAN_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
BOOST_ENDIAN_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
return detail::endian_store_impl<T, sizeof(T), order::native, N, Order>()( p, v );
}
@ -51,11 +50,11 @@ namespace detail
// same endianness, same size
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_store_impl<T, N, O, N, O>
template<class T, std::size_t N, order O> struct endian_store_impl<T, N, O, N, O>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
std::memcpy( p, &v, N );
}
@ -63,11 +62,11 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_store
// same size, reverse endianness
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl<T, N, O1, N, O2>
template<class T, std::size_t N, order O1, order O2> struct endian_store_impl<T, N, O1, N, O2>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( is_trivially_copyable<T>::value );
typename integral_by_size<N>::type tmp;
std::memcpy( &tmp, &v, N );
@ -80,11 +79,11 @@ template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(
// truncating store 2 -> 1
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::little>
template<class T, order Order> struct endian_store_impl<T, 2, Order, 1, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 2 ];
boost::endian::endian_store<T, 2, order::little>( tmp, v );
@ -93,11 +92,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::big>
template<class T, order Order> struct endian_store_impl<T, 2, Order, 1, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 2 ];
boost::endian::endian_store<T, 2, order::big>( tmp, v );
@ -108,11 +107,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2,
// truncating store 4 -> 1
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::little>
template<class T, order Order> struct endian_store_impl<T, 4, Order, 1, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::little>( tmp, v );
@ -121,11 +120,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::big>
template<class T, order Order> struct endian_store_impl<T, 4, Order, 1, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::big>( tmp, v );
@ -136,11 +135,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
// truncating store 4 -> 2
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::little>
template<class T, order Order> struct endian_store_impl<T, 4, Order, 2, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::little>( tmp, v );
@ -150,11 +149,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::big>
template<class T, order Order> struct endian_store_impl<T, 4, Order, 2, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::big>( tmp, v );
@ -166,11 +165,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
// truncating store 4 -> 3
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::little>
template<class T, order Order> struct endian_store_impl<T, 4, Order, 3, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::little>( tmp, v );
@ -181,11 +180,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::big>
template<class T, order Order> struct endian_store_impl<T, 4, Order, 3, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::big>( tmp, v );
@ -198,11 +197,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4,
// truncating store 8 -> 1
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 1, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -211,11 +210,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 1, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
@ -226,11 +225,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
// truncating store 8 -> 2
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 2, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -240,11 +239,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 2, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
@ -256,11 +255,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
// truncating store 8 -> 3
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 3, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -271,11 +270,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 3, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
@ -288,11 +287,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
// truncating store 8 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 4, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -304,11 +303,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 4, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
@ -322,11 +321,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
// truncating store 8 -> 5
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 5, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -339,11 +338,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 5, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
@ -358,11 +357,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
// truncating store 8 -> 6
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 6, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -376,11 +375,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 6, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
@ -396,11 +395,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
// truncating store 8 -> 7
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::little>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 7, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
@ -415,11 +414,11 @@ template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8,
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::big>
template<class T, order Order> struct endian_store_impl<T, 8, Order, 7, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
BOOST_ENDIAN_STATIC_ASSERT( std::is_integral<T>::value || std::is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );

View File

@ -6,8 +6,7 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <cstdint>
#include <cstddef>
namespace boost
@ -23,29 +22,29 @@ template<std::size_t N> struct integral_by_size
template<> struct integral_by_size<1>
{
typedef uint8_t type;
typedef std::uint8_t type;
};
template<> struct integral_by_size<2>
{
typedef uint16_t type;
typedef std::uint16_t type;
};
template<> struct integral_by_size<4>
{
typedef uint32_t type;
typedef std::uint32_t type;
};
template<> struct integral_by_size<8>
{
typedef uint64_t type;
typedef std::uint64_t type;
};
#if defined(BOOST_HAS_INT128)
#if defined(__SIZEOF_INT128__)
template<> struct integral_by_size<16>
{
typedef uint128_type type;
typedef __uint128_t type;
};
#endif

View File

@ -6,9 +6,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <type_traits>
namespace boost
{
@ -17,13 +15,13 @@ namespace endian
namespace detail
{
template<class T> struct negation: boost::integral_constant<bool, !T::value> {};
template<class T> struct negation: std::integral_constant<bool, !T::value> {};
template<class T> struct is_scoped_enum:
boost::conditional<
boost::is_enum<T>::value,
negation< boost::is_convertible<T, int> >,
boost::false_type
std::conditional<
std::is_enum<T>::value,
negation< std::is_convertible<T, int> >,
std::false_type
>::type
{
};

View File

@ -7,13 +7,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <boost/type_traits/has_trivial_copy.hpp>
#include <boost/type_traits/has_trivial_assign.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
# include <type_traits>
#endif
#include <type_traits>
namespace boost
{
@ -28,8 +22,8 @@ using std::is_trivially_copyable;
#else
template<class T> struct is_trivially_copyable: boost::integral_constant<bool,
boost::has_trivial_copy<T>::value && boost::has_trivial_assign<T>::value && boost::has_trivial_destructor<T>::value> {};
template<class T> struct is_trivially_copyable: std::integral_constant<bool,
std::has_trivial_copy<T>::value && std::has_trivial_assign<T>::value && std::has_trivial_destructor<T>::value> {};
#endif

View File

@ -6,8 +6,6 @@
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/scoped_enum.hpp>
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
@ -43,13 +41,12 @@ namespace boost
namespace endian
{
BOOST_SCOPED_ENUM_START(order)
enum class order
{
big,
little,
native = BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
}; BOOST_SCOPED_ENUM_END
};
} // namespace endian
} // namespace boost

View File

@ -1,23 +0,0 @@
#ifndef BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
defined(BOOST_NO_CXX11_DECLTYPE) || \
defined(BOOST_NO_CXX11_CONSTEXPR) || \
defined(BOOST_NO_CXX11_NOEXCEPT) || \
defined(BOOST_NO_CXX11_SCOPED_ENUMS) || \
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.Endian 1.82 and will be removed in Boost.Endian 1.84. Please open an issue in https://github.com/boostorg/endian if you want it retained.")
#endif
#endif // #ifndef BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED

View File

@ -0,0 +1,10 @@
#ifndef BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#define BOOST_ENDIAN_STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
#endif // BOOST_ENDIAN_DETAIL_STATIC_ASSERT_HPP_INCLUDED

View File

@ -29,8 +29,8 @@ namespace endian
typedef align alignment;
# ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) Align = align::no>
template <order Order, class T, std::size_t n_bits,
align Align = align::no>
using endian = endian_arithmetic<Order, T, n_bits, Align>;
# endif

View File

@ -29,14 +29,14 @@
namespace be = boost::endian;
using std::cout;
using std::endl;
using boost::int8_t;
using boost::uint8_t;
using boost::int16_t;
using boost::uint16_t;
using boost::int32_t;
using boost::uint32_t;
using boost::int64_t;
using boost::uint64_t;
using std::int8_t;
using std::uint8_t;
using std::int16_t;
using std::uint16_t;
using std::int32_t;
using std::uint32_t;
using std::int64_t;
using std::uint64_t;
template <class T> inline T std_endian_reverse(T x) BOOST_NOEXCEPT
{

View File

@ -9,7 +9,7 @@
#include <boost/cstdint.hpp>
#include <cstddef>
template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost::endian::align) Align, class T> void test_arithmetic_( T const& x )
template<boost::endian::order Order, boost::endian::align Align, class T> void test_arithmetic_( T const& x )
{
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y( x );
@ -78,7 +78,7 @@ template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost:
}
}
template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost::endian::align) Align, class T> void test_integral_( T const& x )
template<boost::endian::order Order, boost::endian::align Align, class T> void test_integral_( T const& x )
{
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y( x );

View File

@ -176,17 +176,17 @@ template<class T> void test_np()
int main()
{
test<boost::int8_t>();
test<boost::uint8_t>();
test<std::int8_t>();
test<std::uint8_t>();
test<boost::int16_t>();
test<boost::uint16_t>();
test<std::int16_t>();
test<std::uint16_t>();
test<boost::int32_t>();
test<boost::uint32_t>();
test<std::int32_t>();
test<std::uint32_t>();
test<boost::int64_t>();
test<boost::uint64_t>();
test<std::int64_t>();
test<std::uint64_t>();
test<char>();
test<unsigned char>();