From d31caa413c37d2b36a5439c48437d916c382dac8 Mon Sep 17 00:00:00 2001 From: Beman Date: Mon, 11 Aug 2014 17:17:50 -0400 Subject: [PATCH] Add types native synonyms. All tests now passing, at least on a little endian machine. --- include/boost/endian/types.hpp | 116 ++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 47 deletions(-) diff --git a/include/boost/endian/types.hpp b/include/boost/endian/types.hpp index d640dea..591bdbd 100644 --- a/include/boost/endian/types.hpp +++ b/include/boost/endian/types.hpp @@ -173,26 +173,48 @@ namespace endian typedef endian little_uint56_t; typedef endian little_uint64_t; +# ifdef BOOST_BIG_ENDIAN // unaligned native endian signed integer types - typedef endian native_int8_t; - typedef endian native_int16_t; - typedef endian native_int24_t; - typedef endian native_int32_t; - typedef endian native_int40_t; - typedef endian native_int48_t; - typedef endian native_int56_t; - typedef endian native_int64_t; + 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 endian native_uint8_t; - typedef endian native_uint16_t; - typedef endian native_uint24_t; - typedef endian native_uint32_t; - typedef endian native_uint40_t; - typedef endian native_uint48_t; - typedef endian native_uint56_t; - typedef endian native_uint64_t; + 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; +# 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; +# endif } // namespace boost } // namespace endian @@ -470,37 +492,37 @@ namespace endian char m_value[n_bits/8]; }; - // unaligned native endian specialization - template - class endian< order::native, T, n_bits, align::no > - : cover_operators< endian< order::native, 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 -# ifdef BOOST_BIG_ENDIAN - BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT { detail::store_big_endian(m_value, val); } -# else - BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT { detail::store_little_endian(m_value, val); } -# endif -# endif -# ifdef BOOST_BIG_ENDIAN - endian & operator=(T val) BOOST_NOEXCEPT - { detail::store_big_endian(m_value, val); return *this; } - operator T() const BOOST_NOEXCEPT - { return detail::load_big_endian(m_value); } -# else - endian & operator=(T val) BOOST_NOEXCEPT - { detail::store_little_endian(m_value, val); return *this; } - operator T() const BOOST_NOEXCEPT - { return detail::load_little_endian(m_value); } -# endif - const char* data() const BOOST_NOEXCEPT { return m_value; } - private: - char m_value[n_bits/8]; - }; +// // unaligned native endian specialization +// template +// class endian< order::native, T, n_bits, align::no > +// : cover_operators< endian< order::native, 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 +//# ifdef BOOST_BIG_ENDIAN +// BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT { detail::store_big_endian(m_value, val); } +//# else +// BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT { detail::store_little_endian(m_value, val); } +//# endif +//# endif +//# ifdef BOOST_BIG_ENDIAN +// endian & operator=(T val) BOOST_NOEXCEPT +// { detail::store_big_endian(m_value, val); return *this; } +// operator T() const BOOST_NOEXCEPT +// { return detail::load_big_endian(m_value); } +//# else +// endian & operator=(T val) BOOST_NOEXCEPT +// { detail::store_little_endian(m_value, val); return *this; } +// operator T() const BOOST_NOEXCEPT +// { return detail::load_little_endian(m_value); } +//# endif +// const char* data() const BOOST_NOEXCEPT { return m_value; } +// private: +// char m_value[n_bits/8]; +// }; // align::yes specializations; only n_bits == 16/32/64 supported