Major renaming. Class "endian" becomes class "endian_arithmetic" to mimic the C++ standard's description of such types as "arithmetic types". Rename header accordingly. The convenience typedefs have been changed shorten aligned names, as they are often being, but keeping the unaligned type names relatively short via a simple "_ut" suffix.

This commit is contained in:
Beman
2014-11-19 10:53:11 -05:00
parent 61d9046348
commit fc7733ade1
13 changed files with 1189 additions and 1190 deletions

View File

@ -16,7 +16,7 @@
#include <iostream>
#include <cstdio>
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/static_assert.hpp>
using namespace boost::endian;

View File

@ -12,7 +12,7 @@
#include <boost/endian/detail/disable_warnings.hpp>
#define BOOST_ENDIAN_LOG
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/detail/lightweight_test.hpp>

View File

@ -0,0 +1,438 @@
// boost/endian/arithmetic.hpp -------------------------------------------------------//
// (C) Copyright Darin Adler 2000
// (C) Copyright Beman Dawes 2006, 2009, 2014
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
// Original design developed by Darin Adler based on classes developed by Mark
// Borgerding. Four original class templates were combined into a single endian
// class template by Beman Dawes, who also added the unrolled_byte_loops sign
// partial specialization to correctly extend the sign when cover integer size
// differs from endian representation size.
// TODO: When a compiler supporting constexpr becomes available, try possible uses.
#ifndef BOOST_ENDIAN_HPP
#define BOOST_ENDIAN_HPP
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
#endif
#ifdef BOOST_ENDIAN_LOG
# include <iostream>
#endif
#if defined(__BORLANDC__) || defined( __CODEGEARC__)
# pragma pack(push, 1)
#endif
#include <boost/config.hpp>
#include <boost/predef/detail/endian_compat.h>
#include <boost/endian/conversion.hpp>
#include <boost/endian/buffers.hpp>
#define BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
#include <boost/endian/detail/cover_operators.hpp>
#undef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
#include <boost/type_traits/is_signed.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/scoped_enum_emulation.hpp>
#include <iosfwd>
#include <climits>
# if CHAR_BIT != 8
# 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
# if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
# ifndef BOOST_ENDIAN_EXPLICIT_CTORS
# define BOOST_ENDIAN_EXPLICIT_OPT
# else
# define BOOST_ENDIAN_EXPLICIT_OPT explicit
# endif
//---------------------------------- synopsis ----------------------------------------//
namespace boost
{
namespace endian
{
#ifndef BOOST_ENDIAN_ORDER_ENUM_DEFINED
BOOST_SCOPED_ENUM_START(order)
{
big, little,
# ifdef BOOST_BIG_ENDIAN
native = big
# else
native = little
# endif
}; BOOST_SCOPED_ENUM_END
# define BOOST_ENDIAN_ORDER_ENUM_DEFINED
#endif
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) A = align::no>
class endian_arithmetic;
// big endian floating point aligned types
typedef endian_arithmetic<order::big, float, 32, align::yes> big_float32_t;
typedef endian_arithmetic<order::big, double, 64, align::yes> big_float64_t;
// little endian floating point aligned types
typedef endian_arithmetic<order::little, float, 32, align::yes> little_float32_t;
typedef endian_arithmetic<order::little, double, 64, align::yes> little_float64_t;
// big endian floating point unaligned types
typedef endian_arithmetic<order::big, float, 32, align::no> big_float32_ut;
typedef endian_arithmetic<order::big, double, 64, align::no> big_float64_ut;
// little endian floating point unaligned types
typedef endian_arithmetic<order::little, float, 32, align::no> little_float32_ut;
typedef endian_arithmetic<order::little, double, 64, align::no> little_float64_ut;
// big endian signed integer aligned types
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_t;
typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_t;
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_t;
// big endian unsigned integer aligned types
typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_t;
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_t;
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_t;
// little endian signed integer aligned types
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_t;
typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_t;
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_t;
// little endian unsigned integer aligned types
typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_t;
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_t;
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_t;
// aligned native endian typedefs are not provided because
// <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_ut;
typedef endian_arithmetic<order::big, int_least16_t, 16> big_int16_ut;
typedef endian_arithmetic<order::big, int_least32_t, 24> big_int24_ut;
typedef endian_arithmetic<order::big, int_least32_t, 32> big_int32_ut;
typedef endian_arithmetic<order::big, int_least64_t, 40> big_int40_ut;
typedef endian_arithmetic<order::big, int_least64_t, 48> big_int48_ut;
typedef endian_arithmetic<order::big, int_least64_t, 56> big_int56_ut;
typedef endian_arithmetic<order::big, int_least64_t, 64> big_int64_ut;
// big endian unsigned integer unaligned types
typedef endian_arithmetic<order::big, uint_least8_t, 8> big_uint8_ut;
typedef endian_arithmetic<order::big, uint_least16_t, 16> big_uint16_ut;
typedef endian_arithmetic<order::big, uint_least32_t, 24> big_uint24_ut;
typedef endian_arithmetic<order::big, uint_least32_t, 32> big_uint32_ut;
typedef endian_arithmetic<order::big, uint_least64_t, 40> big_uint40_ut;
typedef endian_arithmetic<order::big, uint_least64_t, 48> big_uint48_ut;
typedef endian_arithmetic<order::big, uint_least64_t, 56> big_uint56_ut;
typedef endian_arithmetic<order::big, uint_least64_t, 64> big_uint64_ut;
// little endian signed integer unaligned types
typedef endian_arithmetic<order::little, int_least8_t, 8> little_int8_ut;
typedef endian_arithmetic<order::little, int_least16_t, 16> little_int16_ut;
typedef endian_arithmetic<order::little, int_least32_t, 24> little_int24_ut;
typedef endian_arithmetic<order::little, int_least32_t, 32> little_int32_ut;
typedef endian_arithmetic<order::little, int_least64_t, 40> little_int40_ut;
typedef endian_arithmetic<order::little, int_least64_t, 48> little_int48_ut;
typedef endian_arithmetic<order::little, int_least64_t, 56> little_int56_ut;
typedef endian_arithmetic<order::little, int_least64_t, 64> little_int64_ut;
// little endian unsigned integer unaligned types
typedef endian_arithmetic<order::little, uint_least8_t, 8> little_uint8_ut;
typedef endian_arithmetic<order::little, uint_least16_t, 16> little_uint16_ut;
typedef endian_arithmetic<order::little, uint_least32_t, 24> little_uint24_ut;
typedef endian_arithmetic<order::little, uint_least32_t, 32> little_uint32_ut;
typedef endian_arithmetic<order::little, uint_least64_t, 40> little_uint40_ut;
typedef endian_arithmetic<order::little, uint_least64_t, 48> little_uint48_ut;
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_ut;
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_ut;
# ifdef BOOST_BIG_ENDIAN
// native endian signed integer unaligned types
typedef big_int8_ut native_int8_ut;
typedef big_int16_ut native_int16_ut;
typedef big_int24_ut native_int24_ut;
typedef big_int32_ut native_int32_ut;
typedef big_int40_ut native_int40_ut;
typedef big_int48_ut native_int48_ut;
typedef big_int56_ut native_int56_ut;
typedef big_int64_ut native_int64_ut;
// native endian unsigned integer unaligned types
typedef big_uint8_ut native_uint8_ut;
typedef big_uint16_ut native_uint16_ut;
typedef big_uint24_ut native_uint24_ut;
typedef big_uint32_ut native_uint32_ut;
typedef big_uint40_ut native_uint40_ut;
typedef big_uint48_ut native_uint48_ut;
typedef big_uint56_ut native_uint56_ut;
typedef big_uint64_ut native_uint64_ut;
// native endian floating point types
typedef big_float32_ut native_float32_ut;
typedef big_float64_ut native_float64_ut;
typedef big_float32_t native_float32_t;
typedef big_float64_t native_float64_t;
# else
// native endian signed integer unaligned types
typedef little_int8_ut native_int8_ut;
typedef little_int16_ut native_int16_ut;
typedef little_int24_ut native_int24_ut;
typedef little_int32_ut native_int32_ut;
typedef little_int40_ut native_int40_ut;
typedef little_int48_ut native_int48_ut;
typedef little_int56_ut native_int56_ut;
typedef little_int64_ut native_int64_ut;
// native endian unsigned integer unaligned types
typedef little_uint8_ut native_uint8_ut;
typedef little_uint16_ut native_uint16_ut;
typedef little_uint24_ut native_uint24_ut;
typedef little_uint32_ut native_uint32_ut;
typedef little_uint40_ut native_uint40_ut;
typedef little_uint48_ut native_uint48_ut;
typedef little_uint56_ut native_uint56_ut;
typedef little_uint64_ut native_uint64_ut;
// native endian floating point types
typedef little_float32_ut native_float32_ut;
typedef little_float64_ut native_float64_ut;
typedef little_float32_t native_float32_t;
typedef little_float64_t native_float64_t;
# endif
} // namespace boost
} // namespace endian
//---------------------------------- end synopsis ------------------------------------//
namespace boost
{
namespace endian
{
// endian class template specializations ---------------------------------------------//
// Specializations that represent unaligned bytes.
// Taking an integer type as a parameter provides a nice way to pass both
// the size and signness of the desired integer and get the appropriate
// corresponding integer type for the interface.
// unaligned integer big endian specialization
template <typename T, std::size_t n_bits>
class endian_arithmetic< order::big, T, n_bits, align::no >
: public endian_buffer< order::big, T, n_bits, align::no >,
cover_operators<endian_arithmetic<order::big, T, n_bits>, T>
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
detail::store_big_endian<T, n_bits/8>(this->m_value, val);
}
# endif
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
{ detail::store_big_endian<T, n_bits/8>(this->m_value, val); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned float big endian specialization
template <>
class endian_arithmetic< order::big, float, 32, align::no >
: public endian_buffer< order::big, float, 32, align::no >,
cover_operators< endian_arithmetic< order::big, float, 32 >, float >
{
public:
typedef float value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); }
# endif
endian_arithmetic& operator=(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned double big endian specialization
template <>
class endian_arithmetic< order::big, double, 64, align::no >
: public endian_buffer< order::big, double, 64, align::no >,
cover_operators< endian_arithmetic< order::big, double, 64 >, double >
{
public:
typedef double value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); }
# endif
endian_arithmetic& operator=(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned float little endian specialization
template <>
class endian_arithmetic< order::little, float, 32, align::no >
: public endian_buffer< order::little, float, 32, align::no >,
cover_operators< endian_arithmetic< order::little, float, 32 >, float >
{
public:
typedef float value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); }
# endif
endian_arithmetic& operator=(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned double little endian specialization
template <>
class endian_arithmetic< order::little, double, 64, align::no >
: public endian_buffer< order::little, double, 64, align::no >,
cover_operators< endian_arithmetic< order::little, double, 64 >, double >
{
public:
typedef double value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); }
# endif
endian_arithmetic& operator=(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned little endian specialization
template <typename T, std::size_t n_bits>
class endian_arithmetic< order::little, T, n_bits, align::no >
: public endian_buffer< order::little, T, n_bits, align::no >,
cover_operators< endian_arithmetic< order::little, T, n_bits >, T >
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
detail::store_little_endian<T, n_bits/8>(this->m_value, val);
}
# endif
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
{ detail::store_little_endian<T, n_bits/8>(this->m_value, val); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// align::yes specializations; only n_bits == 16/32/64 supported
// aligned big endian specialization
template <typename T, std::size_t n_bits>
class endian_arithmetic<order::big, T, n_bits, align::yes>
: public endian_buffer< order::big, T, n_bits, align::yes >,
cover_operators<endian_arithmetic<order::big, T, n_bits, align::yes>, T>
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "big, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
this->m_value = ::boost::endian::big_endian_value(val);
}
# endif
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
{
this->m_value = ::boost::endian::big_endian_value(val);
return *this;
}
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// aligned little endian specialization
template <typename T, std::size_t n_bits>
class endian_arithmetic<order::little, T, n_bits, align::yes>
: public endian_buffer< order::little, T, n_bits, align::yes >,
cover_operators<endian_arithmetic<order::little, T, n_bits, align::yes>, T>
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "little, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
this->m_value = ::boost::endian::little_endian_value(val);
}
# endif
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
{
this->m_value = ::boost::endian::little_endian_value(val);
return *this;
}
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
} // namespace endian
} // namespace boost
#if defined(__BORLANDC__) || defined( __CODEGEARC__)
# pragma pack(pop)
#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // BOOST_ENDIAN_HPP

View File

@ -84,136 +84,136 @@ namespace endian
class endian_buffer;
// aligned big endian floating point types
typedef endian_buffer<order::big, float, 32, align::yes> big_align_floatbuf32_t;
typedef endian_buffer<order::big, double, 64, align::yes> big_align_floatbuf64_t;
typedef endian_buffer<order::big, float, 32, align::yes> big_floatbuf32_t;
typedef endian_buffer<order::big, double, 64, align::yes> big_floatbuf64_t;
// aligned little endian floating point types
typedef endian_buffer<order::little, float, 32, align::yes> little_align_floatbuf32_t;
typedef endian_buffer<order::little, double, 64, align::yes> little_align_floatbuf64_t;
typedef endian_buffer<order::little, float, 32, align::yes> little_floatbuf32_t;
typedef endian_buffer<order::little, double, 64, align::yes> little_floatbuf64_t;
// unaligned big endian floating point types
typedef endian_buffer<order::big, float, 32, align::no> big_floatbuf32_t;
typedef endian_buffer<order::big, double, 64, align::no> big_floatbuf64_t;
typedef endian_buffer<order::big, float, 32, align::no> big_floatbuf32_ut;
typedef endian_buffer<order::big, double, 64, align::no> big_floatbuf64_ut;
// unaligned little endian floating point types
typedef endian_buffer<order::little, float, 32, align::no> little_floatbuf32_t;
typedef endian_buffer<order::little, double, 64, align::no> little_floatbuf64_t;
typedef endian_buffer<order::little, float, 32, align::no> little_floatbuf32_ut;
typedef endian_buffer<order::little, double, 64, align::no> little_floatbuf64_ut;
// aligned big endian signed integer types
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_align_buf16_t;
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_align_buf32_t;
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_align_buf64_t;
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_buf16_t;
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_buf32_t;
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_buf64_t;
// aligned big endian unsigned integer types
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_align_ubuf16_t;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_align_ubuf32_t;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_align_ubuf64_t;
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_ubuf16_t;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_ubuf32_t;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_ubuf64_t;
// aligned little endian signed integer types
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_align_buf16_t;
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_align_buf32_t;
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_align_buf64_t;
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_buf16_t;
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_buf32_t;
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_buf64_t;
// aligned little endian unsigned integer types
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_align_ubuf16_t;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_align_ubuf32_t;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_align_ubuf64_t;
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_ubuf16_t;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_ubuf32_t;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_ubuf64_t;
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
// unaligned big endian signed integer types
typedef endian_buffer<order::big, int_least8_t, 8> big_buf8_t;
typedef endian_buffer<order::big, int_least16_t, 16> big_buf16_t;
typedef endian_buffer<order::big, int_least32_t, 24> big_buf24_t;
typedef endian_buffer<order::big, int_least32_t, 32> big_buf32_t;
typedef endian_buffer<order::big, int_least64_t, 40> big_buf40_t;
typedef endian_buffer<order::big, int_least64_t, 48> big_buf48_t;
typedef endian_buffer<order::big, int_least64_t, 56> big_buf56_t;
typedef endian_buffer<order::big, int_least64_t, 64> big_buf64_t;
typedef endian_buffer<order::big, int_least8_t, 8> big_buf8_ut;
typedef endian_buffer<order::big, int_least16_t, 16> big_buf16_ut;
typedef endian_buffer<order::big, int_least32_t, 24> big_buf24_ut;
typedef endian_buffer<order::big, int_least32_t, 32> big_buf32_ut;
typedef endian_buffer<order::big, int_least64_t, 40> big_buf40_ut;
typedef endian_buffer<order::big, int_least64_t, 48> big_buf48_ut;
typedef endian_buffer<order::big, int_least64_t, 56> big_buf56_ut;
typedef endian_buffer<order::big, int_least64_t, 64> big_buf64_ut;
// unaligned big endian unsigned integer types
typedef endian_buffer<order::big, uint_least8_t, 8> big_ubuf8_t;
typedef endian_buffer<order::big, uint_least16_t, 16> big_ubuf16_t;
typedef endian_buffer<order::big, uint_least32_t, 24> big_ubuf24_t;
typedef endian_buffer<order::big, uint_least32_t, 32> big_ubuf32_t;
typedef endian_buffer<order::big, uint_least64_t, 40> big_ubuf40_t;
typedef endian_buffer<order::big, uint_least64_t, 48> big_ubuf48_t;
typedef endian_buffer<order::big, uint_least64_t, 56> big_ubuf56_t;
typedef endian_buffer<order::big, uint_least64_t, 64> big_ubuf64_t;
typedef endian_buffer<order::big, uint_least8_t, 8> big_ubuf8_ut;
typedef endian_buffer<order::big, uint_least16_t, 16> big_ubuf16_ut;
typedef endian_buffer<order::big, uint_least32_t, 24> big_ubuf24_ut;
typedef endian_buffer<order::big, uint_least32_t, 32> big_ubuf32_ut;
typedef endian_buffer<order::big, uint_least64_t, 40> big_ubuf40_ut;
typedef endian_buffer<order::big, uint_least64_t, 48> big_ubuf48_ut;
typedef endian_buffer<order::big, uint_least64_t, 56> big_ubuf56_ut;
typedef endian_buffer<order::big, uint_least64_t, 64> big_ubuf64_ut;
// unaligned little endian signed integer types
typedef endian_buffer<order::little, int_least8_t, 8> little_buf8_t;
typedef endian_buffer<order::little, int_least16_t, 16> little_buf16_t;
typedef endian_buffer<order::little, int_least32_t, 24> little_buf24_t;
typedef endian_buffer<order::little, int_least32_t, 32> little_buf32_t;
typedef endian_buffer<order::little, int_least64_t, 40> little_buf40_t;
typedef endian_buffer<order::little, int_least64_t, 48> little_buf48_t;
typedef endian_buffer<order::little, int_least64_t, 56> little_buf56_t;
typedef endian_buffer<order::little, int_least64_t, 64> little_buf64_t;
typedef endian_buffer<order::little, int_least8_t, 8> little_buf8_ut;
typedef endian_buffer<order::little, int_least16_t, 16> little_buf16_ut;
typedef endian_buffer<order::little, int_least32_t, 24> little_buf24_ut;
typedef endian_buffer<order::little, int_least32_t, 32> little_buf32_ut;
typedef endian_buffer<order::little, int_least64_t, 40> little_buf40_ut;
typedef endian_buffer<order::little, int_least64_t, 48> little_buf48_ut;
typedef endian_buffer<order::little, int_least64_t, 56> little_buf56_ut;
typedef endian_buffer<order::little, int_least64_t, 64> little_buf64_ut;
// unaligned little endian unsigned integer types
typedef endian_buffer<order::little, uint_least8_t, 8> little_ubuf8_t;
typedef endian_buffer<order::little, uint_least16_t, 16> little_ubuf16_t;
typedef endian_buffer<order::little, uint_least32_t, 24> little_ubuf24_t;
typedef endian_buffer<order::little, uint_least32_t, 32> little_ubuf32_t;
typedef endian_buffer<order::little, uint_least64_t, 40> little_ubuf40_t;
typedef endian_buffer<order::little, uint_least64_t, 48> little_ubuf48_t;
typedef endian_buffer<order::little, uint_least64_t, 56> little_ubuf56_t;
typedef endian_buffer<order::little, uint_least64_t, 64> little_ubuf64_t;
typedef endian_buffer<order::little, uint_least8_t, 8> little_ubuf8_ut;
typedef endian_buffer<order::little, uint_least16_t, 16> little_ubuf16_ut;
typedef endian_buffer<order::little, uint_least32_t, 24> little_ubuf24_ut;
typedef endian_buffer<order::little, uint_least32_t, 32> little_ubuf32_ut;
typedef endian_buffer<order::little, uint_least64_t, 40> little_ubuf40_ut;
typedef endian_buffer<order::little, uint_least64_t, 48> little_ubuf48_ut;
typedef endian_buffer<order::little, uint_least64_t, 56> little_ubuf56_ut;
typedef endian_buffer<order::little, uint_least64_t, 64> little_ubuf64_ut;
# ifdef BOOST_BIG_ENDIAN
// unaligned native endian signed integer types
typedef big_buf8_t native_buf8_t;
typedef big_buf16_t native_buf16_t;
typedef big_buf24_t native_buf24_t;
typedef big_buf32_t native_buf32_t;
typedef big_buf40_t native_buf40_t;
typedef big_buf48_t native_buf48_t;
typedef big_buf56_t native_buf56_t;
typedef big_buf64_t native_buf64_t;
typedef big_buf8_ut native_buf8_ut;
typedef big_buf16_ut native_buf16_ut;
typedef big_buf24_ut native_buf24_ut;
typedef big_buf32_ut native_buf32_ut;
typedef big_buf40_ut native_buf40_ut;
typedef big_buf48_ut native_buf48_ut;
typedef big_buf56_ut native_buf56_ut;
typedef big_buf64_ut native_buf64_ut;
// unaligned native endian unsigned integer types
typedef big_ubuf8_t native_ubuf8_t;
typedef big_ubuf16_t native_ubuf16_t;
typedef big_ubuf24_t native_ubuf24_t;
typedef big_ubuf32_t native_ubuf32_t;
typedef big_ubuf40_t native_ubuf40_t;
typedef big_ubuf48_t native_ubuf48_t;
typedef big_ubuf56_t native_ubuf56_t;
typedef big_ubuf64_t native_ubuf64_t;
typedef big_ubuf8_ut native_ubuf8_ut;
typedef big_ubuf16_ut native_ubuf16_ut;
typedef big_ubuf24_ut native_ubuf24_ut;
typedef big_ubuf32_ut native_ubuf32_ut;
typedef big_ubuf40_ut native_ubuf40_ut;
typedef big_ubuf48_ut native_ubuf48_ut;
typedef big_ubuf56_ut native_ubuf56_ut;
typedef big_ubuf64_ut native_ubuf64_ut;
// native endian floating point types
typedef big_floatbuf32_ut native_floatbuf32_ut;
typedef big_floatbuf64_ut native_floatbuf64_ut;
typedef big_floatbuf32_t native_floatbuf32_t;
typedef big_floatbuf64_t native_floatbuf64_t;
typedef big_align_floatbuf32_t native_align_floatbuf32_t;
typedef big_align_floatbuf64_t native_align_floatbuf64_t;
# else
// unaligned native endian signed integer types
typedef little_buf8_t native_buf8_t;
typedef little_buf16_t native_buf16_t;
typedef little_buf24_t native_buf24_t;
typedef little_buf32_t native_buf32_t;
typedef little_buf40_t native_buf40_t;
typedef little_buf48_t native_buf48_t;
typedef little_buf56_t native_buf56_t;
typedef little_buf64_t native_buf64_t;
typedef little_buf8_ut native_buf8_ut;
typedef little_buf16_ut native_buf16_ut;
typedef little_buf24_ut native_buf24_ut;
typedef little_buf32_ut native_buf32_ut;
typedef little_buf40_ut native_buf40_ut;
typedef little_buf48_ut native_buf48_ut;
typedef little_buf56_ut native_buf56_ut;
typedef little_buf64_ut native_buf64_ut;
// unaligned native endian unsigned integer types
typedef little_ubuf8_t native_ubuf8_t;
typedef little_ubuf16_t native_ubuf16_t;
typedef little_ubuf24_t native_ubuf24_t;
typedef little_ubuf32_t native_ubuf32_t;
typedef little_ubuf40_t native_ubuf40_t;
typedef little_ubuf48_t native_ubuf48_t;
typedef little_ubuf56_t native_ubuf56_t;
typedef little_ubuf64_t native_ubuf64_t;
typedef little_ubuf8_ut native_ubuf8_ut;
typedef little_ubuf16_ut native_ubuf16_ut;
typedef little_ubuf24_ut native_ubuf24_ut;
typedef little_ubuf32_ut native_ubuf32_ut;
typedef little_ubuf40_ut native_ubuf40_ut;
typedef little_ubuf48_ut native_ubuf48_ut;
typedef little_ubuf56_ut native_ubuf56_ut;
typedef little_ubuf64_ut native_ubuf64_ut;
// native endian floating point types
typedef little_floatbuf32_ut native_floatbuf32_ut;
typedef little_floatbuf64_ut native_floatbuf64_ut;
typedef little_floatbuf32_t native_floatbuf32_t;
typedef little_floatbuf64_t native_floatbuf64_t;
typedef little_align_floatbuf32_t native_align_floatbuf32_t;
typedef little_align_floatbuf64_t native_align_floatbuf64_t;
# endif
} // namespace boost
} // namespace endian

View File

@ -1,438 +0,0 @@
// boost/endian/types.hpp ------------------------------------------------------------//
// (C) Copyright Darin Adler 2000
// (C) Copyright Beman Dawes 2006, 2009, 2014
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
// Original design developed by Darin Adler based on classes developed by Mark
// Borgerding. Four original class templates were combined into a single endian
// class template by Beman Dawes, who also added the unrolled_byte_loops sign
// partial specialization to correctly extend the sign when cover integer size
// differs from endian representation size.
// TODO: When a compiler supporting constexpr becomes available, try possible uses.
#ifndef BOOST_ENDIAN_HPP
#define BOOST_ENDIAN_HPP
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
#endif
#ifdef BOOST_ENDIAN_LOG
# include <iostream>
#endif
#if defined(__BORLANDC__) || defined( __CODEGEARC__)
# pragma pack(push, 1)
#endif
#include <boost/config.hpp>
#include <boost/predef/detail/endian_compat.h>
#include <boost/endian/conversion.hpp>
#include <boost/endian/buffers.hpp>
#define BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
#include <boost/endian/detail/cover_operators.hpp>
#undef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
#include <boost/type_traits/is_signed.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/scoped_enum_emulation.hpp>
#include <iosfwd>
#include <climits>
# if CHAR_BIT != 8
# 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
# if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
# ifndef BOOST_ENDIAN_EXPLICIT_CTORS
# define BOOST_ENDIAN_EXPLICIT_OPT
# else
# define BOOST_ENDIAN_EXPLICIT_OPT explicit
# endif
//---------------------------------- synopsis ----------------------------------------//
namespace boost
{
namespace endian
{
#ifndef BOOST_ENDIAN_ORDER_ENUM_DEFINED
BOOST_SCOPED_ENUM_START(order)
{
big, little,
# ifdef BOOST_BIG_ENDIAN
native = big
# else
native = little
# endif
}; BOOST_SCOPED_ENUM_END
# define BOOST_ENDIAN_ORDER_ENUM_DEFINED
#endif
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) A = align::no>
class endian;
// aligned big endian floating point types
typedef endian<order::big, float, 32, align::yes> big_align_float32_t;
typedef endian<order::big, double, 64, align::yes> big_align_float64_t;
// aligned little endian floating point types
typedef endian<order::little, float, 32, align::yes> little_align_float32_t;
typedef endian<order::little, double, 64, align::yes> little_align_float64_t;
// unaligned big endian floating point types
typedef endian<order::big, float, 32, align::no> big_float32_t;
typedef endian<order::big, double, 64, align::no> big_float64_t;
// unaligned little endian floating point types
typedef endian<order::little, float, 32, align::no> little_float32_t;
typedef endian<order::little, double, 64, align::no> little_float64_t;
// aligned big endian signed integer types
typedef endian<order::big, int16_t, 16, align::yes> big_align_int16_t;
typedef endian<order::big, int32_t, 32, align::yes> big_align_int32_t;
typedef endian<order::big, int64_t, 64, align::yes> big_align_int64_t;
// aligned big endian unsigned integer types
typedef endian<order::big, uint16_t, 16, align::yes> big_align_uint16_t;
typedef endian<order::big, uint32_t, 32, align::yes> big_align_uint32_t;
typedef endian<order::big, uint64_t, 64, align::yes> big_align_uint64_t;
// aligned little endian signed integer types
typedef endian<order::little, int16_t, 16, align::yes> little_align_int16_t;
typedef endian<order::little, int32_t, 32, align::yes> little_align_int32_t;
typedef endian<order::little, int64_t, 64, align::yes> little_align_int64_t;
// aligned little endian unsigned integer types
typedef endian<order::little, uint16_t, 16, align::yes> little_align_uint16_t;
typedef endian<order::little, uint32_t, 32, align::yes> little_align_uint32_t;
typedef endian<order::little, uint64_t, 64, align::yes> little_align_uint64_t;
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
// unaligned big endian signed integer types
typedef endian<order::big, int_least8_t, 8> big_int8_t;
typedef endian<order::big, int_least16_t, 16> big_int16_t;
typedef endian<order::big, int_least32_t, 24> big_int24_t;
typedef endian<order::big, int_least32_t, 32> big_int32_t;
typedef endian<order::big, int_least64_t, 40> big_int40_t;
typedef endian<order::big, int_least64_t, 48> big_int48_t;
typedef endian<order::big, int_least64_t, 56> big_int56_t;
typedef endian<order::big, int_least64_t, 64> big_int64_t;
// unaligned big endian unsigned integer types
typedef endian<order::big, uint_least8_t, 8> big_uint8_t;
typedef endian<order::big, uint_least16_t, 16> big_uint16_t;
typedef endian<order::big, uint_least32_t, 24> big_uint24_t;
typedef endian<order::big, uint_least32_t, 32> big_uint32_t;
typedef endian<order::big, uint_least64_t, 40> big_uint40_t;
typedef endian<order::big, uint_least64_t, 48> big_uint48_t;
typedef endian<order::big, uint_least64_t, 56> big_uint56_t;
typedef endian<order::big, uint_least64_t, 64> big_uint64_t;
// unaligned little endian signed integer types
typedef endian<order::little, int_least8_t, 8> little_int8_t;
typedef endian<order::little, int_least16_t, 16> little_int16_t;
typedef endian<order::little, int_least32_t, 24> little_int24_t;
typedef endian<order::little, int_least32_t, 32> little_int32_t;
typedef endian<order::little, int_least64_t, 40> little_int40_t;
typedef endian<order::little, int_least64_t, 48> little_int48_t;
typedef endian<order::little, int_least64_t, 56> little_int56_t;
typedef endian<order::little, int_least64_t, 64> little_int64_t;
// unaligned little endian unsigned integer types
typedef endian<order::little, uint_least8_t, 8> little_uint8_t;
typedef endian<order::little, uint_least16_t, 16> little_uint16_t;
typedef endian<order::little, uint_least32_t, 24> little_uint24_t;
typedef endian<order::little, uint_least32_t, 32> little_uint32_t;
typedef endian<order::little, uint_least64_t, 40> little_uint40_t;
typedef endian<order::little, uint_least64_t, 48> little_uint48_t;
typedef endian<order::little, uint_least64_t, 56> little_uint56_t;
typedef endian<order::little, uint_least64_t, 64> little_uint64_t;
# ifdef BOOST_BIG_ENDIAN
// unaligned native endian signed integer types
typedef big_int8_t native_int8_t;
typedef big_int16_t native_int16_t;
typedef big_int24_t native_int24_t;
typedef big_int32_t native_int32_t;
typedef big_int40_t native_int40_t;
typedef big_int48_t native_int48_t;
typedef big_int56_t native_int56_t;
typedef big_int64_t native_int64_t;
// unaligned native endian unsigned integer types
typedef big_uint8_t native_uint8_t;
typedef big_uint16_t native_uint16_t;
typedef big_uint24_t native_uint24_t;
typedef big_uint32_t native_uint32_t;
typedef big_uint40_t native_uint40_t;
typedef big_uint48_t native_uint48_t;
typedef big_uint56_t native_uint56_t;
typedef big_uint64_t native_uint64_t;
// native endian floating point types
typedef big_float32_t native_float32_t;
typedef big_float64_t native_float64_t;
typedef big_align_float32_t native_align_float32_t;
typedef big_align_float64_t native_align_float64_t;
# else
// unaligned native endian signed integer types
typedef little_int8_t native_int8_t;
typedef little_int16_t native_int16_t;
typedef little_int24_t native_int24_t;
typedef little_int32_t native_int32_t;
typedef little_int40_t native_int40_t;
typedef little_int48_t native_int48_t;
typedef little_int56_t native_int56_t;
typedef little_int64_t native_int64_t;
// unaligned native endian unsigned integer types
typedef little_uint8_t native_uint8_t;
typedef little_uint16_t native_uint16_t;
typedef little_uint24_t native_uint24_t;
typedef little_uint32_t native_uint32_t;
typedef little_uint40_t native_uint40_t;
typedef little_uint48_t native_uint48_t;
typedef little_uint56_t native_uint56_t;
typedef little_uint64_t native_uint64_t;
// native endian floating point types
typedef little_float32_t native_float32_t;
typedef little_float64_t native_float64_t;
typedef little_align_float32_t native_align_float32_t;
typedef little_align_float64_t native_align_float64_t;
# endif
} // namespace boost
} // namespace endian
//---------------------------------- end synopsis ------------------------------------//
namespace boost
{
namespace endian
{
// endian class template specializations ---------------------------------------------//
// Specializations that represent unaligned bytes.
// Taking an integer type as a parameter provides a nice way to pass both
// the size and signness of the desired integer and get the appropriate
// corresponding integer type for the interface.
// unaligned integer big endian specialization
template <typename T, std::size_t n_bits>
class endian< order::big, T, n_bits, align::no >
: public endian_buffer< order::big, T, n_bits, align::no >,
cover_operators<endian<order::big, T, n_bits>, T>
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
detail::store_big_endian<T, n_bits/8>(this->m_value, val);
}
# endif
endian & operator=(T val) BOOST_NOEXCEPT
{ detail::store_big_endian<T, n_bits/8>(this->m_value, val); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned float big endian specialization
template <>
class endian< order::big, float, 32, align::no >
: public endian_buffer< order::big, float, 32, align::no >,
cover_operators< endian< order::big, float, 32 >, float >
{
public:
typedef float value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); }
# endif
endian & operator=(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned double big endian specialization
template <>
class endian< order::big, double, 64, align::no >
: public endian_buffer< order::big, double, 64, align::no >,
cover_operators< endian< order::big, double, 64 >, double >
{
public:
typedef double value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); }
# endif
endian & operator=(value_type val) BOOST_NOEXCEPT
{ detail::big_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned float little endian specialization
template <>
class endian< order::little, float, 32, align::no >
: public endian_buffer< order::little, float, 32, align::no >,
cover_operators< endian< order::little, float, 32 >, float >
{
public:
typedef float value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); }
# endif
endian & operator=(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned double little endian specialization
template <>
class endian< order::little, double, 64, align::no >
: public endian_buffer< order::little, double, 64, align::no >,
cover_operators< endian< order::little, double, 64 >, double >
{
public:
typedef double value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); }
# endif
endian & operator=(value_type val) BOOST_NOEXCEPT
{ detail::little_reverse_copy(val, this->m_value); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// unaligned little endian specialization
template <typename T, std::size_t n_bits>
class endian< order::little, T, n_bits, align::no >
: public endian_buffer< order::little, T, n_bits, align::no >,
cover_operators< endian< order::little, T, n_bits >, T >
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
detail::store_little_endian<T, n_bits/8>(this->m_value, val);
}
# endif
endian & operator=(T val) BOOST_NOEXCEPT
{ detail::store_little_endian<T, n_bits/8>(this->m_value, val); return *this; }
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// align::yes specializations; only n_bits == 16/32/64 supported
// aligned big endian specialization
template <typename T, std::size_t n_bits>
class endian<order::big, T, n_bits, align::yes>
: public endian_buffer< order::big, T, n_bits, align::yes >,
cover_operators<endian<order::big, T, n_bits, align::yes>, T>
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "big, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
this->m_value = ::boost::endian::big_endian_value(val);
}
# endif
endian& operator=(T val) BOOST_NOEXCEPT
{
this->m_value = ::boost::endian::big_endian_value(val);
return *this;
}
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
// aligned little endian specialization
template <typename T, std::size_t n_bits>
class endian<order::little, T, n_bits, align::yes>
: public endian_buffer< order::little, T, n_bits, align::yes >,
cover_operators<endian<order::little, T, n_bits, align::yes>, T>
{
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
public:
typedef T value_type;
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "little, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
this->m_value = ::boost::endian::little_endian_value(val);
}
# endif
endian& operator=(T val) BOOST_NOEXCEPT
{
this->m_value = ::boost::endian::little_endian_value(val);
return *this;
}
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
};
} // namespace endian
} // namespace boost
#if defined(__BORLANDC__) || defined( __CODEGEARC__)
# pragma pack(pop)
#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // BOOST_ENDIAN_HPP

View File

@ -15,7 +15,7 @@
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <cassert>
@ -23,59 +23,59 @@ using namespace boost::endian;
union U
{
big_int8_t big_8;
big_int16_t big_16;
big_int24_t big_24;
big_int32_t big_32;
big_int40_t big_40;
big_int48_t big_48;
big_int56_t big_56;
big_int64_t big_64;
big_int8_ut big_8;
big_int16_ut big_16;
big_int24_ut big_24;
big_int32_ut big_32;
big_int40_ut big_40;
big_int48_ut big_48;
big_int56_ut big_56;
big_int64_ut big_64;
big_uint8_t big_u8;
big_uint16_t big_u16;
big_uint24_t big_u24;
big_uint32_t big_u32;
big_uint40_t big_u40;
big_uint48_t big_u48;
big_uint56_t big_u56;
big_uint64_t big_u64;
big_uint8_ut big_u8;
big_uint16_ut big_u16;
big_uint24_ut big_u24;
big_uint32_ut big_u32;
big_uint40_ut big_u40;
big_uint48_ut big_u48;
big_uint56_ut big_u56;
big_uint64_ut big_u64;
little_int8_t little_8;
little_int16_t little_16;
little_int24_t little_24;
little_int32_t little_32;
little_int40_t little_40;
little_int48_t little_48;
little_int56_t little_56;
little_int64_t little_64;
little_int8_ut little_8;
little_int16_ut little_16;
little_int24_ut little_24;
little_int32_ut little_32;
little_int40_ut little_40;
little_int48_ut little_48;
little_int56_ut little_56;
little_int64_ut little_64;
little_uint8_t little_u8;
little_uint16_t little_u16;
little_uint24_t little_u24;
little_uint32_t little_u32;
little_uint40_t little_u40;
little_uint48_t little_u48;
little_uint56_t little_u56;
little_uint64_t little_u64;
little_uint8_ut little_u8;
little_uint16_ut little_u16;
little_uint24_ut little_u24;
little_uint32_ut little_u32;
little_uint40_ut little_u40;
little_uint48_ut little_u48;
little_uint56_ut little_u56;
little_uint64_ut little_u64;
native_int8_t native_8;
native_int16_t native_16;
native_int24_t native_24;
native_int32_t native_32;
native_int40_t native_40;
native_int48_t native_48;
native_int56_t native_56;
native_int64_t native_64;
native_int8_ut native_8;
native_int16_ut native_16;
native_int24_ut native_24;
native_int32_ut native_32;
native_int40_ut native_40;
native_int48_ut native_48;
native_int56_ut native_56;
native_int64_ut native_64;
native_uint8_t native_u8;
native_uint16_t native_u16;
native_uint24_t native_u24;
native_uint32_t native_u32;
native_uint40_t native_u40;
native_uint48_t native_u48;
native_uint56_t native_u56;
native_uint64_t native_u64;
native_uint8_ut native_u8;
native_uint16_ut native_u16;
native_uint24_ut native_u24;
native_uint32_ut native_u32;
native_uint40_ut native_u40;
native_uint48_ut native_u48;
native_uint56_ut native_u56;
native_uint64_ut native_u64;
};
U foo;

View File

@ -44,7 +44,7 @@
#define BOOST_ENDIAN_LOG
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_main.hpp>
@ -208,67 +208,67 @@ void op_test_aux()
Test<T1, unsigned long>::test();
Test<T1, long long>::test();
Test<T1, unsigned long long>::test();
Test<T1, be::big_align_int16_t>::test();
Test<T1, be::big_align_int32_t>::test();
Test<T1, be::big_align_int64_t>::test();
Test<T1, be::big_align_uint16_t>::test();
Test<T1, be::big_align_uint32_t>::test();
Test<T1, be::big_align_uint64_t>::test();
Test<T1, be::little_align_int16_t>::test();
Test<T1, be::little_align_int32_t>::test();
Test<T1, be::little_align_int64_t>::test();
Test<T1, be::little_align_uint16_t>::test();
Test<T1, be::little_align_uint32_t>::test();
Test<T1, be::little_align_uint64_t>::test();
Test<T1, be::big_int8_t>::test();
Test<T1, be::big_int16_t>::test();
Test<T1, be::big_int24_t>::test();
Test<T1, be::big_int32_t>::test();
Test<T1, be::big_int40_t>::test();
Test<T1, be::big_int48_t>::test();
Test<T1, be::big_int56_t>::test();
Test<T1, be::big_int64_t>::test();
Test<T1, be::big_uint8_t>::test();
Test<T1, be::big_uint16_t>::test();
Test<T1, be::big_uint24_t>::test();
Test<T1, be::big_uint32_t>::test();
Test<T1, be::big_uint40_t>::test();
Test<T1, be::big_uint64_t>::test();
Test<T1, be::little_int16_t>::test();
Test<T1, be::little_int24_t>::test();
Test<T1, be::little_int32_t>::test();
Test<T1, be::little_int64_t>::test();
Test<T1, be::little_uint16_t>::test();
Test<T1, be::little_uint32_t>::test();
Test<T1, be::little_uint56_t>::test();
Test<T1, be::little_uint64_t>::test();
Test<T1, be::native_int16_t>::test();
Test<T1, be::native_int24_t>::test();
Test<T1, be::native_int32_t>::test();
Test<T1, be::native_int64_t>::test();
Test<T1, be::big_int8_ut>::test();
Test<T1, be::big_int16_ut>::test();
Test<T1, be::big_int24_ut>::test();
Test<T1, be::big_int32_ut>::test();
Test<T1, be::big_int40_ut>::test();
Test<T1, be::big_int48_ut>::test();
Test<T1, be::big_int56_ut>::test();
Test<T1, be::big_int64_ut>::test();
Test<T1, be::big_uint8_ut>::test();
Test<T1, be::big_uint16_ut>::test();
Test<T1, be::big_uint24_ut>::test();
Test<T1, be::big_uint32_ut>::test();
Test<T1, be::big_uint40_ut>::test();
Test<T1, be::big_uint64_ut>::test();
Test<T1, be::little_int16_ut>::test();
Test<T1, be::little_int24_ut>::test();
Test<T1, be::little_int32_ut>::test();
Test<T1, be::little_int64_ut>::test();
Test<T1, be::little_uint16_ut>::test();
Test<T1, be::little_uint32_ut>::test();
Test<T1, be::little_uint56_ut>::test();
Test<T1, be::little_uint64_ut>::test();
Test<T1, be::native_int16_ut>::test();
Test<T1, be::native_int24_ut>::test();
Test<T1, be::native_int32_ut>::test();
Test<T1, be::native_int64_ut>::test();
#ifdef BOOST_LONG_ENDIAN_TEST
Test<T1, be::native_uint16_t>::test();
Test<T1, be::native_uint24_t>::test();
Test<T1, be::native_uint32_t>::test();
Test<T1, be::native_uint48_t>::test();
Test<T1, be::native_uint64_t>::test();
Test<T1, be::big_uint48_t>::test();
Test<T1, be::big_uint56_t>::test();
Test<T1, be::little_int8_t>::test();
Test<T1, be::little_int56_t>::test();
Test<T1, be::little_int40_t>::test();
Test<T1, be::little_int48_t>::test();
Test<T1, be::little_uint8_t>::test();
Test<T1, be::little_uint24_t>::test();
Test<T1, be::little_uint40_t>::test();
Test<T1, be::little_uint48_t>::test();
Test<T1, be::native_int8_t>::test();
Test<T1, be::native_int40_t>::test();
Test<T1, be::native_int48_t>::test();
Test<T1, be::native_int56_t>::test();
Test<T1, be::native_uint8_t>::test();
Test<T1, be::native_uint40_t>::test();
Test<T1, be::native_uint56_t>::test();
Test<T1, be::native_uint16_ut>::test();
Test<T1, be::native_uint24_ut>::test();
Test<T1, be::native_uint32_ut>::test();
Test<T1, be::native_uint48_ut>::test();
Test<T1, be::native_uint64_ut>::test();
Test<T1, be::big_uint48_ut>::test();
Test<T1, be::big_uint56_ut>::test();
Test<T1, be::little_int8_ut>::test();
Test<T1, be::little_int56_ut>::test();
Test<T1, be::little_int40_ut>::test();
Test<T1, be::little_int48_ut>::test();
Test<T1, be::little_uint8_ut>::test();
Test<T1, be::little_uint24_ut>::test();
Test<T1, be::little_uint40_ut>::test();
Test<T1, be::little_uint48_ut>::test();
Test<T1, be::native_int8_ut>::test();
Test<T1, be::native_int40_ut>::test();
Test<T1, be::native_int48_ut>::test();
Test<T1, be::native_int56_ut>::test();
Test<T1, be::native_uint8_ut>::test();
Test<T1, be::native_uint40_ut>::test();
Test<T1, be::native_uint56_ut>::test();
#endif
}
@ -286,61 +286,61 @@ void op_test()
op_test_aux<Test, unsigned long>();
op_test_aux<Test, long long>();
op_test_aux<Test, unsigned long long>();
op_test_aux<Test, be::big_align_int16_t>();
op_test_aux<Test, be::big_align_int32_t>();
op_test_aux<Test, be::big_align_int64_t>();
op_test_aux<Test, be::little_align_int16_t>();
op_test_aux<Test, be::little_align_int32_t>();
op_test_aux<Test, be::little_align_int64_t>();
#ifdef BOOST_LONG_ENDIAN_TEST
op_test_aux<Test, be::big_int8_t>();
op_test_aux<Test, be::big_int16_t>();
op_test_aux<Test, be::big_int24_t>();
op_test_aux<Test, be::big_int32_t>();
op_test_aux<Test, be::big_int40_t>();
op_test_aux<Test, be::big_int48_t>();
op_test_aux<Test, be::big_int56_t>();
op_test_aux<Test, be::big_int64_t>();
op_test_aux<Test, be::big_uint8_t>();
op_test_aux<Test, be::big_uint16_t>();
op_test_aux<Test, be::big_uint24_t>();
op_test_aux<Test, be::big_uint32_t>();
op_test_aux<Test, be::big_uint40_t>();
op_test_aux<Test, be::big_uint48_t>();
op_test_aux<Test, be::big_uint56_t>();
op_test_aux<Test, be::big_uint64_t>();
op_test_aux<Test, be::little_int8_t>();
op_test_aux<Test, be::little_int16_t>();
op_test_aux<Test, be::little_int24_t>();
op_test_aux<Test, be::little_int32_t>();
op_test_aux<Test, be::little_int40_t>();
op_test_aux<Test, be::little_int48_t>();
op_test_aux<Test, be::little_int56_t>();
op_test_aux<Test, be::little_int64_t>();
op_test_aux<Test, be::little_uint8_t>();
op_test_aux<Test, be::little_uint16_t>();
op_test_aux<Test, be::little_uint24_t>();
op_test_aux<Test, be::little_uint32_t>();
op_test_aux<Test, be::little_uint40_t>();
op_test_aux<Test, be::little_uint48_t>();
op_test_aux<Test, be::little_uint56_t>();
op_test_aux<Test, be::little_uint64_t>();
op_test_aux<Test, be::native_int8_t>();
op_test_aux<Test, be::native_int16_t>();
op_test_aux<Test, be::native_int24_t>();
op_test_aux<Test, be::native_int32_t>();
op_test_aux<Test, be::native_int40_t>();
op_test_aux<Test, be::native_int48_t>();
op_test_aux<Test, be::native_int56_t>();
op_test_aux<Test, be::native_int64_t>();
op_test_aux<Test, be::native_uint8_t>();
op_test_aux<Test, be::native_uint16_t>();
op_test_aux<Test, be::native_uint24_t>();
op_test_aux<Test, be::native_uint32_t>();
op_test_aux<Test, be::native_uint40_t>();
op_test_aux<Test, be::native_uint48_t>();
op_test_aux<Test, be::native_uint56_t>();
op_test_aux<Test, be::native_uint64_t>();
#ifdef BOOST_LONG_ENDIAN_TEST
op_test_aux<Test, be::big_int8_ut>();
op_test_aux<Test, be::big_int16_ut>();
op_test_aux<Test, be::big_int24_ut>();
op_test_aux<Test, be::big_int32_ut>();
op_test_aux<Test, be::big_int40_ut>();
op_test_aux<Test, be::big_int48_ut>();
op_test_aux<Test, be::big_int56_ut>();
op_test_aux<Test, be::big_int64_ut>();
op_test_aux<Test, be::big_uint8_ut>();
op_test_aux<Test, be::big_uint16_ut>();
op_test_aux<Test, be::big_uint24_ut>();
op_test_aux<Test, be::big_uint32_ut>();
op_test_aux<Test, be::big_uint40_ut>();
op_test_aux<Test, be::big_uint48_ut>();
op_test_aux<Test, be::big_uint56_ut>();
op_test_aux<Test, be::big_uint64_ut>();
op_test_aux<Test, be::little_int8_ut>();
op_test_aux<Test, be::little_int16_ut>();
op_test_aux<Test, be::little_int24_ut>();
op_test_aux<Test, be::little_int32_ut>();
op_test_aux<Test, be::little_int40_ut>();
op_test_aux<Test, be::little_int48_ut>();
op_test_aux<Test, be::little_int56_ut>();
op_test_aux<Test, be::little_int64_ut>();
op_test_aux<Test, be::little_uint8_ut>();
op_test_aux<Test, be::little_uint16_ut>();
op_test_aux<Test, be::little_uint24_ut>();
op_test_aux<Test, be::little_uint32_ut>();
op_test_aux<Test, be::little_uint40_ut>();
op_test_aux<Test, be::little_uint48_ut>();
op_test_aux<Test, be::little_uint56_ut>();
op_test_aux<Test, be::little_uint64_ut>();
op_test_aux<Test, be::native_int8_ut>();
op_test_aux<Test, be::native_int16_ut>();
op_test_aux<Test, be::native_int24_ut>();
op_test_aux<Test, be::native_int32_ut>();
op_test_aux<Test, be::native_int40_ut>();
op_test_aux<Test, be::native_int48_ut>();
op_test_aux<Test, be::native_int56_ut>();
op_test_aux<Test, be::native_int64_ut>();
op_test_aux<Test, be::native_uint8_ut>();
op_test_aux<Test, be::native_uint16_ut>();
op_test_aux<Test, be::native_uint24_ut>();
op_test_aux<Test, be::native_uint32_ut>();
op_test_aux<Test, be::native_uint40_ut>();
op_test_aux<Test, be::native_uint48_ut>();
op_test_aux<Test, be::native_uint56_ut>();
op_test_aux<Test, be::native_uint64_ut>();
#endif
}
@ -350,8 +350,8 @@ void test_inserter_and_extractor()
{
std::cout << "test inserter and extractor..." << std::endl;
be::big_uint64_t bu64(0x010203040506070ULL);
be::little_uint64_t lu64(0x010203040506070ULL);
be::big_uint64_ut bu64(0x010203040506070ULL);
be::little_uint64_ut lu64(0x010203040506070ULL);
uint64_t x;
@ -368,13 +368,13 @@ void test_inserter_and_extractor()
ss.clear();
ss << 0x010203040506070ULL;
be::big_uint64_t bu64z(0);
be::big_uint64_ut bu64z(0);
ss >> bu64z;
BOOST_TEST_EQ(bu64z, bu64);
ss.clear();
ss << 0x010203040506070ULL;
be::little_uint64_t lu64z(0);
be::little_uint64_ut lu64z(0);
ss >> lu64z;
BOOST_TEST_EQ(lu64z, lu64);
@ -382,7 +382,7 @@ void test_inserter_and_extractor()
}
void f_big_int32_t(be::big_int32_t) {}
void f_big_int32_ut(be::big_int32_ut) {}
// main ------------------------------------------------------------------------------//
@ -392,10 +392,10 @@ int cpp_main(int, char * [])
// make sure some simple things work
be::big_int32_t o1(1);
be::big_int32_t o2(2L);
be::big_int32_t o3(3LL);
be::big_int64_t o4(1);
be::big_int32_ut o1(1);
be::big_int32_ut o2(2L);
be::big_int32_ut o3(3LL);
be::big_int64_ut o4(1);
// use cases; if BOOST_ENDIAN_LOG is defined, will output to clog info on
// what overloads and conversions are actually being performed.
@ -403,14 +403,14 @@ int cpp_main(int, char * [])
be::endian_log = true;
std::clog << "set up test values\n";
be::big_int32_t big(12345);
be::little_uint16_t little_u(10);
be::big_int64_t result;
be::big_int32_ut big(12345);
be::little_uint16_ut little_u(10);
be::big_int64_ut result;
// this is the use case that is so irritating that it caused the endian
// constructors to be made non-explicit
std::clog << "\nf(1234) where f(big_int32_t)\n";
f_big_int32_t(1234);
std::clog << "\nf(1234) where f(big_int32_ut)\n";
f_big_int32_ut(1234);
std::clog << "\nresult = big\n";
result = big;
@ -470,8 +470,8 @@ int cpp_main(int, char * [])
// test from Roland Schwarz that detected ambiguities; these ambiguities
// were eliminated by BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
unsigned u;
be::little_uint32_t u1;
be::little_uint32_t u2;
be::little_uint32_ut u1;
be::little_uint32_ut u2;
u = 9;
u1 = 1;
@ -481,7 +481,7 @@ int cpp_main(int, char * [])
// variations to detect ambiguities
be::little_uint32_t u3 = u1 + 5;
be::little_uint32_ut u3 = u1 + 5;
u3 = u1 + 5u;
if (u1 == 5)
@ -496,7 +496,7 @@ int cpp_main(int, char * [])
u2 = u1 + 5u;
// one more wrinkle
be::little_uint16_t u4(3);
be::little_uint16_ut u4(3);
u4 = 3;
std::clog << "\nu2 = u1 + u4\n";
u2 = u1 + u4;

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <boost/timer/timer.hpp>
#include <iostream>
@ -119,84 +119,84 @@ namespace
void test_big_align_int16()
{
cout << "<tr><td>16-bit aligned big endian</td>";
time<int16_t, big_align_int16_t>();
time<int16_t, big_int16_t>();
cout << "</tr>\n";
}
void test_little_align_int16()
{
cout << "<tr><td>16-bit aligned little endian</td>";
time<int16_t, little_align_int16_t>();
time<int16_t, little_int16_t>();
cout << "</tr>\n";
}
void test_big_int16()
{
cout << "<tr><td>16-bit unaligned big endian</td>";
time<int16_t, big_int16_t>();
time<int16_t, big_int16_ut>();
cout << "</tr>\n";
}
void test_little_int16()
{
cout << "<tr><td>16-bit unaligned little endian</td>";
time<int16_t, little_int16_t>();
time<int16_t, little_int16_ut>();
cout << "</tr>\n";
}
void test_big_align_int32()
{
cout << "<tr><td>32-bit aligned big endian</td>";
time<int32_t, big_align_int32_t>();
time<int32_t, big_int32_t>();
cout << "</tr>\n";
}
void test_little_align_int32()
{
cout << "<tr><td>32-bit aligned little endian</td>";
time<int32_t, little_align_int32_t>();
time<int32_t, little_int32_t>();
cout << "</tr>\n";
}
void test_big_int32()
{
cout << "<tr><td>32-bit unaligned big endian</td>";
time<int32_t, big_int32_t>();
time<int32_t, big_int32_ut>();
cout << "</tr>\n";
}
void test_little_int32()
{
cout << "<tr><td>32-bit unaligned little endian</td>";
time<int32_t, little_int32_t>();
time<int32_t, little_int32_ut>();
cout << "</tr>\n";
}
void test_big_align_int64()
{
cout << "<tr><td>64-bit aligned big endian</td>";
time<int64_t, big_align_int64_t>();
time<int64_t, big_int64_t>();
cout << "</tr>\n";
}
void test_little_align_int64()
{
cout << "<tr><td>64-bit aligned little endian</td>";
time<int64_t, little_align_int64_t>();
time<int64_t, little_int64_t>();
cout << "</tr>\n";
}
void test_big_int64()
{
cout << "<tr><td>64-bit unaligned big endian</td>";
time<int64_t, big_int64_t>();
time<int64_t, big_int64_ut>();
cout << "</tr>\n";
}
void test_little_int64()
{
cout << "<tr><td>64-bit unaligned little endian</td>";
time<int64_t, little_int64_t>();
time<int64_t, little_int64_ut>();
cout << "</tr>\n";
}

View File

@ -128,7 +128,6 @@ Global
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|Win32.Build.0 = Release|Win32
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|x64.ActiveCfg = Release|Win32
{36BF451A-EAEF-4140-92E4-6EA461A26107}.Debug|Win32.ActiveCfg = Debug|Win32
{36BF451A-EAEF-4140-92E4-6EA461A26107}.Debug|Win32.Build.0 = Debug|Win32
{36BF451A-EAEF-4140-92E4-6EA461A26107}.Debug|x64.ActiveCfg = Debug|Win32
{36BF451A-EAEF-4140-92E4-6EA461A26107}.Release|Win32.ActiveCfg = Release|Win32
{36BF451A-EAEF-4140-92E4-6EA461A26107}.Release|Win32.Build.0 = Release|Win32

View File

@ -16,7 +16,7 @@
#include "speed_test_functions.hpp"
#include <boost/endian/conversion.hpp>
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <boost/timer/timer.hpp>
#include <iostream>
@ -96,63 +96,63 @@ namespace
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
}
void test_big_align_int16()
void test_big_int16()
{
cout << "<tr><td>16-bit aligned big endian</td>";
time<int16_t, big_align_int16_t>(user::return_x_big_align_int16);
time<int16_t, big_align_int16_t>(user::return_x_value_big_align_int16);
time<int16_t, big_align_int16_t>(user::return_x_in_place_big_align_int16);
time<int16_t, big_align_int16_t>(user::return_x_big_align_int16);
time<int16_t, big_int16_t>(user::return_x_big_int16);
time<int16_t, big_int16_t>(user::return_x_value_big_int16);
time<int16_t, big_int16_t>(user::return_x_in_place_big_int16);
time<int16_t, big_int16_t>(user::return_x_big_int16);
cout << "</tr>\n";
}
void test_little_align_int16()
void test_little_int16()
{
cout << "<tr><td>16-bit aligned little endian</td>";
time<int16_t, little_align_int16_t>(user::return_x_little_align_int16);
time<int16_t, little_align_int16_t>(user::return_x_value_little_align_int16);
time<int16_t, little_align_int16_t>(user::return_x_in_place_little_align_int16);
time<int16_t, little_align_int16_t>(user::return_x_little_align_int16);
time<int16_t, little_int16_t>(user::return_x_little_int16);
time<int16_t, little_int16_t>(user::return_x_value_little_int16);
time<int16_t, little_int16_t>(user::return_x_in_place_little_int16);
time<int16_t, little_int16_t>(user::return_x_little_int16);
cout << "</tr>\n";
}
void test_big_align_int32()
void test_big_int32()
{
cout << "<tr><td>32-bit aligned big endian</td>";
time<int32_t, big_align_int32_t>(user::return_x_big_align_int32);
time<int32_t, big_align_int32_t>(user::return_x_value_big_align_int32);
time<int32_t, big_align_int32_t>(user::return_x_in_place_big_align_int32);
time<int32_t, big_align_int32_t>(user::return_x_big_align_int32);
time<int32_t, big_int32_t>(user::return_x_big_int32);
time<int32_t, big_int32_t>(user::return_x_value_big_int32);
time<int32_t, big_int32_t>(user::return_x_in_place_big_int32);
time<int32_t, big_int32_t>(user::return_x_big_int32);
cout << "</tr>\n";
}
void test_little_align_int32()
void test_little_int32()
{
cout << "<tr><td>32-bit aligned little endian</td>";
time<int32_t, little_align_int32_t>(user::return_x_little_align_int32);
time<int32_t, little_align_int32_t>(user::return_x_value_little_align_int32);
time<int32_t, little_align_int32_t>(user::return_x_in_place_little_align_int32);
time<int32_t, little_align_int32_t>(user::return_x_little_align_int32);
time<int32_t, little_int32_t>(user::return_x_little_int32);
time<int32_t, little_int32_t>(user::return_x_value_little_int32);
time<int32_t, little_int32_t>(user::return_x_in_place_little_int32);
time<int32_t, little_int32_t>(user::return_x_little_int32);
cout << "</tr>\n";
}
void test_big_align_int64()
void test_big_int64()
{
cout << "<tr><td>64-bit aligned big endian</td>";
time<int64_t, big_align_int64_t>(user::return_x_big_align_int64);
time<int64_t, big_align_int64_t>(user::return_x_value_big_align_int64);
time<int64_t, big_align_int64_t>(user::return_x_in_place_big_align_int64);
time<int64_t, big_align_int64_t>(user::return_x_big_align_int64);
time<int64_t, big_int64_t>(user::return_x_big_int64);
time<int64_t, big_int64_t>(user::return_x_value_big_int64);
time<int64_t, big_int64_t>(user::return_x_in_place_big_int64);
time<int64_t, big_int64_t>(user::return_x_big_int64);
cout << "</tr>\n";
}
void test_little_align_int64()
void test_little_int64()
{
cout << "<tr><td>64-bit aligned little endian</td>";
time<int64_t, little_align_int64_t>(user::return_x_little_align_int64);
time<int64_t, little_align_int64_t>(user::return_x_value_little_align_int64);
time<int64_t, little_align_int64_t>(user::return_x_in_place_little_align_int64);
time<int64_t, little_align_int64_t>(user::return_x_little_align_int64);
time<int64_t, little_int64_t>(user::return_x_little_int64);
time<int64_t, little_int64_t>(user::return_x_value_little_int64);
time<int64_t, little_int64_t>(user::return_x_in_place_little_int64);
time<int64_t, little_int64_t>(user::return_x_little_int64);
cout << "</tr>\n";
}
@ -182,12 +182,12 @@ int cpp_main(int argc, char* argv[])
"</tr>\n"
;
test_big_align_int16();
test_little_align_int16();
test_big_align_int32();
test_little_align_int32();
test_big_align_int64();
test_little_align_int64();
test_big_int16();
test_little_int16();
test_big_int32();
test_little_int32();
test_big_int64();
test_little_int64();
cout << "\n</table>\n</body>\n</html>\n";

View File

@ -20,31 +20,31 @@
namespace user
{
int16_t return_x_big_align_int16(int16_t x, big_align_int16_t) BOOST_NOEXCEPT {return x;}
int16_t return_x_little_align_int16(int16_t x, little_align_int16_t) BOOST_NOEXCEPT {return x;}
int16_t return_x_value_big_align_int16(int16_t x, big_align_int16_t) BOOST_NOEXCEPT {return big_endian_value(x);}
int16_t return_x_value_little_align_int16(int16_t x, little_align_int16_t) BOOST_NOEXCEPT {return little_endian_value(x);}
int16_t return_x_in_place_big_align_int16(int16_t x, big_align_int16_t) BOOST_NOEXCEPT {big_endian(x);return x;}
int16_t return_x_in_place_little_align_int16(int16_t x, little_align_int16_t) BOOST_NOEXCEPT {little_endian(x);return x;}
int16_t return_y_big_align_int16(int16_t x, big_align_int16_t y) BOOST_NOEXCEPT {return y;}
int16_t return_y_little_align_int16(int16_t x, little_align_int16_t y) BOOST_NOEXCEPT {return y;}
int16_t return_x_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT {return x;}
int16_t return_x_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT {return x;}
int16_t return_x_value_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT {return big_endian_value(x);}
int16_t return_x_value_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT {return little_endian_value(x);}
int16_t return_x_in_place_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT {big_endian(x);return x;}
int16_t return_x_in_place_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT {little_endian(x);return x;}
int16_t return_y_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT {return y;}
int16_t return_y_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT {return y;}
int32_t return_x_big_align_int32(int32_t x, big_align_int32_t) BOOST_NOEXCEPT {return x;}
int32_t return_x_little_align_int32(int32_t x, little_align_int32_t) BOOST_NOEXCEPT {return x;}
int32_t return_x_value_big_align_int32(int32_t x, big_align_int32_t) BOOST_NOEXCEPT {return big_endian_value(x);}
int32_t return_x_value_little_align_int32(int32_t x, little_align_int32_t) BOOST_NOEXCEPT {return little_endian_value(x);}
int32_t return_x_in_place_big_align_int32(int32_t x, big_align_int32_t) BOOST_NOEXCEPT {big_endian(x);return x;}
int32_t return_x_in_place_little_align_int32(int32_t x, little_align_int32_t) BOOST_NOEXCEPT {little_endian(x);return x;}
int32_t return_y_big_align_int32(int32_t x, big_align_int32_t y) BOOST_NOEXCEPT {return y;}
int32_t return_y_little_align_int32(int32_t x, little_align_int32_t y) BOOST_NOEXCEPT {return y;}
int32_t return_x_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT {return x;}
int32_t return_x_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT {return x;}
int32_t return_x_value_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT {return big_endian_value(x);}
int32_t return_x_value_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT {return little_endian_value(x);}
int32_t return_x_in_place_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT {big_endian(x);return x;}
int32_t return_x_in_place_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT {little_endian(x);return x;}
int32_t return_y_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT {return y;}
int32_t return_y_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT {return y;}
int64_t return_x_big_align_int64(int64_t x, big_align_int64_t) BOOST_NOEXCEPT {return x;}
int64_t return_x_little_align_int64(int64_t x, little_align_int64_t) BOOST_NOEXCEPT {return x;}
int64_t return_x_value_big_align_int64(int64_t x, big_align_int64_t) BOOST_NOEXCEPT {return big_endian_value(x);}
int64_t return_x_value_little_align_int64(int64_t x, little_align_int64_t) BOOST_NOEXCEPT {return little_endian_value(x);}
int64_t return_x_in_place_big_align_int64(int64_t x, big_align_int64_t) BOOST_NOEXCEPT {big_endian(x);return x;}
int64_t return_x_in_place_little_align_int64(int64_t x, little_align_int64_t) BOOST_NOEXCEPT {little_endian(x);return x;}
int64_t return_y_big_align_int64(int64_t x, big_align_int64_t y) BOOST_NOEXCEPT {return y;}
int64_t return_y_little_align_int64(int64_t x, little_align_int64_t y) BOOST_NOEXCEPT {return y;}
int64_t return_x_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT {return x;}
int64_t return_x_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT {return x;}
int64_t return_x_value_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT {return big_endian_value(x);}
int64_t return_x_value_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT {return little_endian_value(x);}
int64_t return_x_in_place_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT {big_endian(x);return x;}
int64_t return_x_in_place_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT {little_endian(x);return x;}
int64_t return_y_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT {return y;}
int64_t return_y_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT {return y;}
}

View File

@ -17,39 +17,39 @@
#define BOOST_ENDIAN_SPEED_TEST_FUNCTIONS_HPP
#include <boost/cstdint.hpp>
#include <boost/endian/types.hpp>
#include <boost/endian/arithmetic.hpp>
namespace user
{
using namespace boost;
using namespace boost::endian;
int16_t return_x_big_align_int16(int16_t x, big_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_little_align_int16(int16_t x, little_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_value_big_align_int16(int16_t x, big_align_int16_t) BOOST_NOEXCEPT;
int16_t return_x_value_little_align_int16(int16_t x, little_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_in_place_big_align_int16(int16_t x, big_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_in_place_little_align_int16(int16_t x, little_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_y_big_align_int16(int16_t x, big_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_y_little_align_int16(int16_t x, little_align_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_value_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT;
int16_t return_x_value_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_in_place_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT;
int16_t return_x_in_place_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
int16_t return_y_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT;
int16_t return_y_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
int32_t return_x_big_align_int32(int32_t x, big_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_little_align_int32(int32_t x, little_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_value_big_align_int32(int32_t x, big_align_int32_t) BOOST_NOEXCEPT;
int32_t return_x_value_little_align_int32(int32_t x, little_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_in_place_big_align_int32(int32_t x, big_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_in_place_little_align_int32(int32_t x, little_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_y_big_align_int32(int32_t x, big_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_y_little_align_int32(int32_t x, little_align_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_value_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT;
int32_t return_x_value_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_in_place_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT;
int32_t return_x_in_place_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
int32_t return_y_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT;
int32_t return_y_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
int64_t return_x_big_align_int64(int64_t x, big_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_little_align_int64(int64_t x, little_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_value_big_align_int64(int64_t x, big_align_int64_t) BOOST_NOEXCEPT;
int64_t return_x_value_little_align_int64(int64_t x, little_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_in_place_big_align_int64(int64_t x, big_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_in_place_little_align_int64(int64_t x, little_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_y_big_align_int64(int64_t x, big_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_y_little_align_int64(int64_t x, little_align_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_value_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT;
int64_t return_x_value_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_in_place_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT;
int64_t return_x_in_place_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
int64_t return_y_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT;
int64_t return_y_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
}