Add separate big and little specializations for aligned case; the attempt to combine into a single specialization was selecting the unaligned specialization. Rework speed_test to try to get more meaningful results and cover more test cases.

This commit is contained in:
Beman
2013-05-22 08:14:51 -04:00
parent a855a35c57
commit 6f84684e9e
4 changed files with 251 additions and 143 deletions

View File

@@ -314,113 +314,129 @@ usual operations on integers are supplied.</p>
{
namespace endian
{
// C++11 features emulated if not available
enum class <a name="endianness">endianness</a> { big, little, native }; // scoped enum emulated on C++03
enum class <a name="alignment">alignment</a> { unaligned, aligned }; // scoped enum emulated on C++03
enum class <a name="endianness">order</a> {big, little, native};
enum class <a name="alignment">align</a> {no, yes};
template &lt;endianness E, typename T, std::size_t n_bits,
alignment A = alignment::unaligned&gt;
class endian : <a href="../../../boost/endian/detail/cover_operators.hpp">cover_operators</a>&lt; endian&lt;E, T, n_bits, A&gt;, T &gt;
template &lt;order Order, typename T, std::size_t n_bits, align A = align::no&gt;
class endian
{
public:
typedef T value_type;
// if BOOST_ENDIAN_FORCE_PODNESS is defined &amp;&amp; C++11 POD's are not
// available then these two constructors will not be present
<a href="#endian">endian</a>() = default; // = default replaced by {} on C++03
explicit <a href="#explicit-endian">endian</a>(T v);
<a href="#endian">endian</a>() noexcept = default;
explicit <a href="#explicit-endian">endian</a>(T v) noexcept;
endian&amp; <a href="#operator-eq">operator=</a>(T v);
<a href="#operator-T">operator T</a>() const;
const char* <a href="#data">data</a>() const;
endian&amp; <a href="#operator-eq">operator=</a>(T v) noexcept;
<a href="#operator-T">operator T</a>() const noexcept;
const char* <a href="#data">data</a>() const noexcept;
// arithmetic operations; additional operators provided by value_type
value_type operator+(const endian&amp; x) noexcept;
endian&amp; operator+=(endian&amp; x, value_type y) noexcept;
endian&amp; operator-=(endian&amp; x, value_type y) noexcept;
endian&amp; operator*=(endian&amp; x, value_type y) noexcept;
endian&amp; operator/=(endian&amp; x, value_type y) noexcept;
endian&amp; operator%=(endian&amp; x, value_type y) noexcept;
endian&amp; operator&amp;=(endian&amp; x, value_type y) noexcept;
endian&amp; operator|=(endian&amp; x, value_type y) noexcept;
endian&amp; operator^=(endian&amp; x, value_type y) noexcept;
endian&amp; operator&lt;&lt;=(endian&amp; x, value_type y) noexcept;
endian&amp; operator&gt;&gt;=(endian&amp; x, value_type y noexcept;
value_type operator&lt;&lt;(const endian&amp; x, value_type y) noexcept;
value_type operator&gt;&gt;(const endian&amp; x, value_type y) noexcept;
endian&amp; operator++(endian&amp; x) noexcept;
endian&amp; operator--(endian&amp; x) noexcept;
endian operator++(endian&amp; x, int) noexcept;
endian operator--(endian&amp; x, int) noexcept;
};
// unaligned big endian signed integer types
typedef endian&lt; endianness::big, int_least8_t, 8 &gt; big8_t;
typedef endian&lt; endianness::big, int_least16_t, 16 &gt; big16_t;
typedef endian&lt; endianness::big, int_least32_t, 24 &gt; big24_t;
typedef endian&lt; endianness::big, int_least32_t, 32 &gt; big32_t;
typedef endian&lt; endianness::big, int_least64_t, 40 &gt; big40_t;
typedef endian&lt; endianness::big, int_least64_t, 48 &gt; big48_t;
typedef endian&lt; endianness::big, int_least64_t, 56 &gt; big56_t;
typedef endian&lt; endianness::big, int_least64_t, 64 &gt; big64_t;
// unaligned big endian unsigned integer types
typedef endian&lt; endianness::big, uint_least8_t, 8 &gt; ubig8_t;
typedef endian&lt; endianness::big, uint_least16_t, 16 &gt; ubig16_t;
typedef endian&lt; endianness::big, uint_least32_t, 24 &gt; ubig24_t;
typedef endian&lt; endianness::big, uint_least32_t, 32 &gt; ubig32_t;
typedef endian&lt; endianness::big, uint_least64_t, 40 &gt; ubig40_t;
typedef endian&lt; endianness::big, uint_least64_t, 48 &gt; ubig48_t;
typedef endian&lt; endianness::big, uint_least64_t, 56 &gt; ubig56_t;
typedef endian&lt; endianness::big, uint_least64_t, 64 &gt; ubig64_t;
// unaligned little endian signed integer types
typedef endian&lt; endianness::little, int_least8_t, 8 &gt; little8_t;
typedef endian&lt; endianness::little, int_least16_t, 16 &gt; little16_t;
typedef endian&lt; endianness::little, int_least32_t, 24 &gt; little24_t;
typedef endian&lt; endianness::little, int_least32_t, 32 &gt; little32_t;
typedef endian&lt; endianness::little, int_least64_t, 40 &gt; little40_t;
typedef endian&lt; endianness::little, int_least64_t, 48 &gt; little48_t;
typedef endian&lt; endianness::little, int_least64_t, 56 &gt; little56_t;
typedef endian&lt; endianness::little, int_least64_t, 64 &gt; little64_t;
// unaligned little endian unsigned integer types
typedef endian&lt; endianness::little, uint_least8_t, 8 &gt; ulittle8_t;
typedef endian&lt; endianness::little, uint_least16_t, 16 &gt; ulittle16_t;
typedef endian&lt; endianness::little, uint_least32_t, 24 &gt; ulittle24_t;
typedef endian&lt; endianness::little, uint_least32_t, 32 &gt; ulittle32_t;
typedef endian&lt; endianness::little, uint_least64_t, 40 &gt; ulittle40_t;
typedef endian&lt; endianness::little, uint_least64_t, 48 &gt; ulittle48_t;
typedef endian&lt; endianness::little, uint_least64_t, 56 &gt; ulittle56_t;
typedef endian&lt; endianness::little, uint_least64_t, 64 &gt; ulittle64_t;
// unaligned native endian signed integer types
typedef endian&lt; endianness::native, int_least8_t, 8 &gt; native8_t;
typedef endian&lt; endianness::native, int_least16_t, 16 &gt; native16_t;
typedef endian&lt; endianness::native, int_least32_t, 24 &gt; native24_t;
typedef endian&lt; endianness::native, int_least32_t, 32 &gt; native32_t;
typedef endian&lt; endianness::native, int_least64_t, 40 &gt; native40_t;
typedef endian&lt; endianness::native, int_least64_t, 48 &gt; native48_t;
typedef endian&lt; endianness::native, int_least64_t, 56 &gt; native56_t;
typedef endian&lt; endianness::native, int_least64_t, 64 &gt; native64_t;
// unaligned native endian unsigned integer types
typedef endian&lt; endianness::native, uint_least8_t, 8 &gt; unative8_t;
typedef endian&lt; endianness::native, uint_least16_t, 16 &gt; unative16_t;
typedef endian&lt; endianness::native, uint_least32_t, 24 &gt; unative24_t;
typedef endian&lt; endianness::native, uint_least32_t, 32 &gt; unative32_t;
typedef endian&lt; endianness::native, uint_least64_t, 40 &gt; unative40_t;
typedef endian&lt; endianness::native, uint_least64_t, 48 &gt; unative48_t;
typedef endian&lt; endianness::native, uint_least64_t, 56 &gt; unative56_t;
typedef endian&lt; endianness::native, uint_least64_t, 64 &gt; unative64_t;
// These types only present if platform has exact size integers:
// aligned big endian signed integer types
typedef endian&lt; endianness::big, int16_t, 16, alignment::aligned &gt; aligned_big16_t;
typedef endian&lt; endianness::big, int32_t, 32, alignment::aligned &gt; aligned_big32_t;
typedef endian&lt; endianness::big, int64_t, 64, alignment::aligned &gt; aligned_big64_t;
typedef endian&lt;order::big, int16_t, 16, align::yes&gt; big_int16_t;
typedef endian&lt;order::big, int32_t, 32, align::yes&gt; big_int32_t;
typedef endian&lt;order::big, int64_t, 64, align::yes&gt; big_int64_t;
// aligned big endian unsigned integer types
typedef endian&lt; endianness::big, uint16_t, 16, alignment::aligned &gt; aligned_ubig16_t;
typedef endian&lt; endianness::big, uint32_t, 32, alignment::aligned &gt; aligned_ubig32_t;
typedef endian&lt; endianness::big, uint64_t, 64, alignment::aligned &gt; aligned_ubig64_t;
typedef endian&lt;order::big, uint16_t, 16, align::yes&gt; big_uint16_t;
typedef endian&lt;order::big, uint32_t, 32, align::yes&gt; big_uint32_t;
typedef endian&lt;order::big, uint64_t, 64, align::yes&gt; big_uint64_t;
// aligned little endian signed integer types
typedef endian&lt; endianness::little, int16_t, 16, alignment::aligned &gt; aligned_little2_t;
typedef endian&lt; endianness::little, int32_t, 32, alignment::aligned &gt; aligned_little4_t;
typedef endian&lt; endianness::little, int64_t, 64, alignment::aligned &gt; aligned_little8_t;
typedef endian&lt;order::little, int16_t, 16, align::yes&gt; little_int16_t;
typedef endian&lt;order::little, int32_t, 32, align::yes&gt; little_int32_t;
typedef endian&lt;order::little, int64_t, 64, align::yes&gt; little_int64_t;
// aligned little endian unsigned integer types
typedef endian&lt; endianness::little, uint16_t, 16, alignment::aligned &gt; aligned_ulittle2_t;
typedef endian&lt; endianness::little, uint32_t, 32, alignment::aligned &gt; aligned_ulittle4_t;
typedef endian&lt; endianness::little, uint64_t, 64, alignment::aligned &gt; aligned_ulittle8_t;
typedef endian&lt;order::little, uint16_t, 16, align::yes&gt; little_uint16_t;
typedef endian&lt;order::little, uint32_t, 32, align::yes&gt; little_uint32_t;
typedef endian&lt;order::little, uint64_t, 64, align::yes&gt; little_uint64_t;
// aligned native endian typedefs are not provided because
// &lt;cstdint&gt; types are superior for this use case
// unaligned big endian signed integer types
typedef endian&lt;order::big, int_least8_t, 8&gt; big_8_t;
typedef endian&lt;order::big, int_least16_t, 16&gt; big_16_t;
typedef endian&lt;order::big, int_least32_t, 24&gt; big_24_t;
typedef endian&lt;order::big, int_least32_t, 32&gt; big_32_t;
typedef endian&lt;order::big, int_least64_t, 40&gt; big_40_t;
typedef endian&lt;order::big, int_least64_t, 48&gt; big_48_t;
typedef endian&lt;order::big, int_least64_t, 56&gt; big_56_t;
typedef endian&lt;order::big, int_least64_t, 64&gt; big_64_t;
// unaligned big endian unsigned integer types
typedef endian&lt;order::big, uint_least8_t, 8&gt; big_u8_t;
typedef endian&lt;order::big, uint_least16_t, 16&gt; big_u16_t;
typedef endian&lt;order::big, uint_least32_t, 24&gt; big_u24_t;
typedef endian&lt;order::big, uint_least32_t, 32&gt; big_u32_t;
typedef endian&lt;order::big, uint_least64_t, 40&gt; big_u40_t;
typedef endian&lt;order::big, uint_least64_t, 48&gt; big_u48_t;
typedef endian&lt;order::big, uint_least64_t, 56&gt; big_u56_t;
typedef endian&lt;order::big, uint_least64_t, 64&gt; big_u64_t;
// unaligned little endian signed integer types
typedef endian&lt;order::little, int_least8_t, 8&gt; little_8_t;
typedef endian&lt;order::little, int_least16_t, 16&gt; little_16_t;
typedef endian&lt;order::little, int_least32_t, 24&gt; little_24_t;
typedef endian&lt;order::little, int_least32_t, 32&gt; little_32_t;
typedef endian&lt;order::little, int_least64_t, 40&gt; little_40_t;
typedef endian&lt;order::little, int_least64_t, 48&gt; little_48_t;
typedef endian&lt;order::little, int_least64_t, 56&gt; little_56_t;
typedef endian&lt;order::little, int_least64_t, 64&gt; little_64_t;
// unaligned little endian unsigned integer types
typedef endian&lt;order::little, uint_least8_t, 8&gt; little_u8_t;
typedef endian&lt;order::little, uint_least16_t, 16&gt; little_u16_t;
typedef endian&lt;order::little, uint_least32_t, 24&gt; little_u24_t;
typedef endian&lt;order::little, uint_least32_t, 32&gt; little_u32_t;
typedef endian&lt;order::little, uint_least64_t, 40&gt; little_u40_t;
typedef endian&lt;order::little, uint_least64_t, 48&gt; little_u48_t;
typedef endian&lt;order::little, uint_least64_t, 56&gt; little_u56_t;
typedef endian&lt;order::little, uint_least64_t, 64&gt; little_u64_t;
// unaligned native endian signed integer types
typedef endian&lt;order::native, int_least8_t, 8&gt; native_8_t;
typedef endian&lt;order::native, int_least16_t, 16&gt; native_16_t;
typedef endian&lt;order::native, int_least32_t, 24&gt; native_24_t;
typedef endian&lt;order::native, int_least32_t, 32&gt; native_32_t;
typedef endian&lt;order::native, int_least64_t, 40&gt; native_40_t;
typedef endian&lt;order::native, int_least64_t, 48&gt; native_48_t;
typedef endian&lt;order::native, int_least64_t, 56&gt; native_56_t;
typedef endian&lt;order::native, int_least64_t, 64&gt; native_64_t;
// unaligned native endian unsigned integer types
typedef endian&lt;order::native, uint_least8_t, 8&gt; native_u8_t;
typedef endian&lt;order::native, uint_least16_t, 16&gt; native_u16_t;
typedef endian&lt;order::native, uint_least32_t, 24&gt; native_u24_t;
typedef endian&lt;order::native, uint_least32_t, 32&gt; native_u32_t;
typedef endian&lt;order::native, uint_least64_t, 40&gt; native_u40_t;
typedef endian&lt;order::native, uint_least64_t, 48&gt; native_u48_t;
typedef endian&lt;order::native, uint_least64_t, 56&gt; native_u56_t;
typedef endian&lt;order::native, uint_least64_t, 64&gt; native_u64_t;
} // namespace endian
} // namespace boost</pre>
<h3><a name="Members">Members</a></h3>
@@ -577,7 +593,7 @@ sign partial specialization to correctly extend the sign when cover integer size
differs from endian representation size.</p>
<hr>
<p>Last revised:
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->20 May, 2013<!--webbot bot="Timestamp" endspan i-checksum="13976" --></p>
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->21 May, 2013<!--webbot bot="Timestamp" endspan i-checksum="13978" --></p>
<p><EFBFBD> Copyright Beman Dawes, 2006-2009</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>

View File

@@ -285,7 +285,7 @@ namespace endian
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
std::cout << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
detail::store_big_endian<T, n_bits/8>(m_value, val);
}
@@ -295,7 +295,7 @@ namespace endian
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "big, unaligned, " << n_bits << "-bits, convert(" << detail::load_big_endian<T, n_bits/8>(m_value) << ")\n";
std::cout << "big, unaligned, " << n_bits << "-bits, convert(" << detail::load_big_endian<T, n_bits/8>(m_value) << ")\n";
# endif
return detail::load_big_endian<T, n_bits/8>(m_value);
}
@@ -318,7 +318,7 @@ namespace endian
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
std::cout << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
detail::store_little_endian<T, n_bits/8>(m_value, val);
}
@@ -328,7 +328,7 @@ namespace endian
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::clog << "little, unaligned, " << n_bits << "-bits, convert(" << detail::load_little_endian<T, n_bits/8>(m_value) << ")\n";
std::cout << "little, unaligned, " << n_bits << "-bits, convert(" << detail::load_little_endian<T, n_bits/8>(m_value) << ")\n";
# endif
return detail::load_little_endian<T, n_bits/8>(m_value);
}
@@ -367,9 +367,10 @@ namespace endian
// align::yes specializations; only n_bits == 16/32/64 supported
template <BOOST_SCOPED_ENUM(order) Order, typename T, std::size_t n_bits>
class endian<Order, T, n_bits, align::yes>
: cover_operators<endian<Order, T, n_bits, align::yes>, T>
// aligned big endian specialization
template <typename T, std::size_t n_bits>
class endian<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 );
@@ -378,16 +379,66 @@ namespace endian
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian(T val)
: m_value(::boost::endian::convert_value<order::native, Order>(val)) {}
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "big, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
m_value = ::boost::endian::big_endian_value(val);
}
# endif
endian& operator=(T val)
{
m_value = ::boost::endian::convert_value<order::native, Order>(val);
m_value = ::boost::endian::big_endian_value(val);
return *this;
}
operator T() const
{
return ::boost::endian::convert_value<Order, order::native>(m_value);
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "big, aligned, " << n_bits << "-bits, convert(" << ::boost::endian::big_endian_value(m_value) << ")\n";
# endif
return ::boost::endian::big_endian_value(m_value);
}
const char* data() const {return reinterpret_cast<const char*>(&m_value);}
private:
T m_value;
};
// aligned little endian specialization
template <typename T, std::size_t n_bits>
class endian<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
explicit endian(T val)
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "little, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
# endif
m_value = ::boost::endian::little_endian_value(val);
}
# endif
endian& operator=(T val)
{
m_value = ::boost::endian::little_endian_value(val);
return *this;
}
operator T() const
{
# ifdef BOOST_ENDIAN_LOG
if ( endian_log )
std::cout << "little, aligned, " << n_bits << "-bits, convert(" << ::boost::endian::little_endian_value(m_value) << ")\n";
# endif
return ::boost::endian::little_endian_value(m_value);
}
const char* data() const {return reinterpret_cast<const char*>(&m_value);}
private:

View File

@@ -60,7 +60,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1000000</Command>
<Command>"$(TargetDir)\$(TargetName).exe" 1</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -80,7 +80,7 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1000000000</Command>
<Command>"$(TargetDir)\$(TargetName).exe" 10000000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>

View File

@@ -8,6 +8,7 @@
//--------------------------------------------------------------------------------------//
//#define BOOST_ENDIAN_NO_INTRINSICS
//#define BOOST_ENDIAN_LOG
#include <boost/endian/detail/disable_warnings.hpp>
@@ -85,17 +86,57 @@ namespace
//--------------------------------------------------------------------------------------//
template <class T, class EndianT>
result_type test_inc(T x)
template <class T>
result_type test_add_T_to_T(T x)
{
cout << "++ a value..." << endl;
cout << "Add T to T ..." << endl;
result_type result;
result.v = 0;
T y(x);
T y(0);
boost::timer::auto_cpu_timer t(places);
for (uint64_t i = 0; i < n; ++i)
{
++y;
y += x;
}
t.stop();
result.v = static_cast<uint64_t>(y);
boost::timer::cpu_times times = t.elapsed();
result.cpu_time = (times.system + times.user);
t.report();
return result;
}
struct big_tag {};
struct little_tag {};
template <class T>
result_type test_add_conditionally_reversed_T_to_T(T x, big_tag)
{
cout << "add_conditionally_reversed_T_to_T (big)..." << endl;
result_type result;
T y(0);
boost::timer::auto_cpu_timer t(places);
for (uint64_t i = 0; i < n; ++i)
{
y += ::boost::endian::big_endian_value(x);
}
t.stop();
result.v = static_cast<uint64_t>(y);
boost::timer::cpu_times times = t.elapsed();
result.cpu_time = (times.system + times.user);
t.report();
return result;
}
template <class T>
result_type test_add_conditionally_reversed_T_to_T(T x, little_tag)
{
cout << "add_conditionally_reversed_T_to_T (little)..." << endl;
result_type result;
T y(0);
boost::timer::auto_cpu_timer t(places);
for (uint64_t i = 0; i < n; ++i)
{
y += ::boost::endian::little_endian_value(x);
}
t.stop();
result.v = static_cast<uint64_t>(y);
@@ -106,18 +147,15 @@ namespace
}
template <class T, class EndianT>
result_type test_rev_inc(T x)
result_type test_add_Endian_to_T(EndianT x)
{
cout << "reverse, then ++, then reverse a value..." << endl;
cout << "add_Endian_to_T..." << endl;
result_type result;
result.v = 0;
T y(x);
T y(0);
boost::timer::auto_cpu_timer t(places);
for (uint64_t i = 0; i < n; ++i)
{
reverse(y);
++y;
reverse(y);
y += x;
}
t.stop();
result.v = static_cast<uint64_t>(y);
@@ -127,32 +165,15 @@ namespace
return result;
}
template <class T, class EndianT>
result_type test_endian_inc(T x)
{
cout << "++ an endian value..." << endl;
result_type result;
result.v = 0;
EndianT y(x);
boost::timer::auto_cpu_timer t(places);
for (uint64_t i = 0; i < n; ++i)
{
++y;
}
t.stop();
result.v = static_cast<uint64_t>(y);
boost::timer::cpu_times times = t.elapsed();
result.cpu_time = (times.system + times.user);
t.report();
return result;
}
template <class T, class EndianT>
template <class T, BOOST_SCOPED_ENUM(order) Order, class EndianT>
void test(T x)
{
test_inc<T, EndianT>(x);
test_rev_inc<T, EndianT>(x);
test_endian_inc<T, EndianT>(x);
test_add_T_to_T<T>(x);
if (Order == order::big)
test_add_conditionally_reversed_T_to_T<T>(x, big_tag());
else
test_add_conditionally_reversed_T_to_T<T>(x, little_tag());
test_add_Endian_to_T<T, EndianT>(EndianT(x));
}
} // unnamed namespace
@@ -165,23 +186,43 @@ int cpp_main(int argc, char* argv[])
cout << "\nbyte swap intrinsics used: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
cout << endl << "------------------------------------------------------" << endl;
cout << endl << "int16_t, big_16_t" << endl;
test<int16_t, big_16_t>(0x1122);
test<int16_t, order::big, big_16_t>(0x1122);
cout << endl << "int16_t, big_int16_t" << endl;
test<int16_t, order::big, big_int16_t>(0x1122);
cout << endl << "int16_t, little_16_t" << endl;
test<int16_t, little_16_t>(0x1122);
test<int16_t, order::little, little_16_t>(0x1122);
cout << endl << "int16_t, little_int16_t" << endl;
test<int16_t, order::little, little_int16_t>(0x1122);
cout << endl << "------------------------------------------------------" << endl;
cout << endl << "int32_t, big_32_t" << endl;
test<int32_t, big_32_t>(0x11223344);
test<int32_t, order::big, big_32_t>(0x11223344);
cout << endl << "int32_t, big_int32_t" << endl;
test<int32_t, order::big, big_int32_t>(0x11223344);
cout << endl << "int32_t, little_32_t" << endl;
test<int32_t, little_32_t>(0x11223344);
test<int32_t, order::little, little_32_t>(0x11223344);
cout << endl << "int32_t, little_int32_t" << endl;
test<int32_t, order::little, little_int32_t>(0x11223344);
cout << endl << "------------------------------------------------------" << endl;
cout << endl << "int64_t, big_64_t" << endl;
test<int64_t, big_64_t>(0x1122334455667788);
test<int64_t, order::big, big_64_t>(0x1122334455667788);
cout << endl << "int64_t, big_int64_t" << endl;
test<int64_t, order::big, big_int64_t>(0x1122334455667788);
cout << endl << "int64_t, little_64_t" << endl;
test<int64_t, little_64_t>(0x1122334455667788);
test<int64_t, order::little, little_64_t>(0x1122334455667788);
cout << endl << "int64_t, little_int64_t" << endl;
test<int64_t, order::little, little_int64_t>(0x1122334455667788);
cout << endl << "------------------------------------------------------" << endl;
//cout << "float" << endl;
//test<float>(1.2345f);