mirror of
https://github.com/boostorg/endian.git
synced 2025-07-31 21:14:38 +02:00
Finalize buffer and arithmetic decomposition. Finalize name changes. Finalize test cases. Remove cruft. Docs still to do.
This commit is contained in:
@@ -75,7 +75,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h2><a name="Introduction">Introduction</a></h2>
|
<h2><a name="Introduction">Introduction</a></h2>
|
||||||
<p>Header <a href="../include/boost/endian/types.hpp">boost/endian/types.hpp</a>
|
<p>Header <a href="arithmetic.html">boost/endian/arithmetic.hpp</a>
|
||||||
provides integer and floating point binary types with control over
|
provides integer and floating point binary types with control over
|
||||||
byte order, value type, size, and alignment. Typedefs provide easy-to-use names
|
byte order, value type, size, and alignment. Typedefs provide easy-to-use names
|
||||||
for common configurations.</p>
|
for common configurations.</p>
|
||||||
@@ -102,7 +102,7 @@ arithmetic operators are <code>+</code>, <code>+=</code>, <code>-</code>, <code>
|
|||||||
<code>^</code>, <code>^=</code>, <code><<</code>, <code><<=</code>, <code>>></code>,
|
<code>^</code>, <code>^=</code>, <code><<</code>, <code><<=</code>, <code>>></code>,
|
||||||
<code>>>=</code>. Binary relational operators are <code>==</code>, <code>!=</code>,
|
<code>>>=</code>. Binary relational operators are <code>==</code>, <code>!=</code>,
|
||||||
<code><</code>, <code><=</code>, <code>></code>, <code>>=</code>.</p>
|
<code><</code>, <code><=</code>, <code>></code>, <code>>=</code>.</p>
|
||||||
<p>Automatic implicit conversion to the underlying value type is provided. An
|
<p>Automatic implicit conversion to the underlying value type is provided. A
|
||||||
conversion constructor from the underlying value type is provided. </p>
|
conversion constructor from the underlying value type is provided. </p>
|
||||||
<h2><a name="Example">Example</a></h2>
|
<h2><a name="Example">Example</a></h2>
|
||||||
<p>The <a href="../example/endian_example.cpp">endian_example.cpp</a> program writes a
|
<p>The <a href="../example/endian_example.cpp">endian_example.cpp</a> program writes a
|
||||||
|
@@ -40,7 +40,8 @@ public:
|
|||||||
desc_[sizeof(desc_-1)] = '\0';
|
desc_[sizeof(desc_-1)] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
friend void reverse(UDT&);
|
friend UDT reverse_endianness(const UDT&);
|
||||||
|
friend void reverse_endianness_in_place(UDT&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int32_t id_;
|
int32_t id_;
|
||||||
@@ -48,35 +49,36 @@ private:
|
|||||||
char desc_[56]; // '/0'
|
char desc_[56]; // '/0'
|
||||||
};
|
};
|
||||||
|
|
||||||
void reverse(UDT& x)
|
void reverse_endianness_in_place(UDT& x)
|
||||||
{
|
{
|
||||||
reverse(x.id_);
|
reverse_endianness_in_place(x.id_);
|
||||||
reverse(x.value_);
|
reverse_endianness_in_place(x.value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char* [])
|
int main(int, char* [])
|
||||||
{
|
{
|
||||||
UDT x(1, 1.2345f, "Bingo!");
|
UDT x(1, 1.2345f, "Bingo!");
|
||||||
cout << std::hex;
|
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
|
||||||
|
|
||||||
reverse(x);
|
//cout << std::hex;
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(1) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
reverse(x);
|
reverse_endianness_in_place(x);
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(2) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
big_endian(x);
|
reverse_endianness_in_place(x);
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(3) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
little_endian(x);
|
reverse_in_place_unless_native_big(x);
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(4) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
convert<order::little, order::big>(x);
|
reverse_in_place_unless_native_little(x);
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(5) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
convert(x, order::big, order::little);
|
conditional_reverse_in_place<order::little, order::big>(x);
|
||||||
cout << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
cout << "(6) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
|
|
||||||
|
runtime_conditional_reverse_in_place(x, order::big, order::little);
|
||||||
|
cout << "(7) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
||||||
|
@@ -9,65 +9,179 @@
|
|||||||
|
|
||||||
#define _SCL_SECURE_NO_WARNINGS
|
#define _SCL_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#include <boost/endian/detail/disable_warnings.hpp>
|
#include <boost/endian/conversion.hpp>
|
||||||
|
|
||||||
#define BOOST_ENDIAN_LOG
|
|
||||||
#include <boost/endian/arithmetic.hpp>
|
|
||||||
#include <boost/endian/buffers.hpp>
|
#include <boost/endian/buffers.hpp>
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
#include <boost/endian/arithmetic.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// Maximize chance of name clashes for testing purposes
|
// Maximize chance of name clashes for testing purposes
|
||||||
using namespace boost::endian;
|
using namespace boost::endian;
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
//using boost::int8_t;
|
|
||||||
//using boost::uint8_t;
|
|
||||||
//using boost::int16_t;
|
|
||||||
//using boost::uint16_t;
|
|
||||||
//using boost::int32_t;
|
|
||||||
//using boost::uint32_t;
|
|
||||||
//using boost::int64_t;
|
|
||||||
//using boost::uint64_t;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
|
void read(void* data, std::size_t sz); // for exposition
|
||||||
|
void write(const void* data, std::size_t sz); // for exposition
|
||||||
|
const int32_t fee(100); // for exposition
|
||||||
|
|
||||||
|
int main(int, char *[])
|
||||||
{
|
{
|
||||||
} // unnamed namespace
|
|
||||||
|
|
||||||
int cpp_main(int, char *[])
|
|
||||||
{
|
{
|
||||||
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
|
// Q: Should endian_buffer supply "value_type operator value_type() const noexcept"?
|
||||||
|
// A: No. The whole point of the endian_buffers is to prevent high-cost hidden
|
||||||
|
// conversions. If an implicit conversion operator is supplied, hidden conversions
|
||||||
|
// can occur.
|
||||||
|
|
||||||
big_int32_t i1(1), i2(2), i3;
|
big_buf32_t v(5);
|
||||||
big_buf32_t b1(1), b2(2), b3;
|
int32_t x;
|
||||||
|
x = v * v; // error: operator not defined & no conversion available
|
||||||
|
x = v.value() * v.value(); // OK, conversion visable. "cvt" or "native" better name?
|
||||||
|
|
||||||
cout << "endian buffer tests" << endl;
|
|
||||||
cout << "compute\n";
|
|
||||||
i3 = i1 + 5;
|
|
||||||
cout << "test\n";
|
|
||||||
BOOST_TEST(i3 == 6);
|
|
||||||
cout << "compute\n";
|
|
||||||
i3 = i1 + i2;
|
|
||||||
cout << "test\n";
|
|
||||||
BOOST_TEST(i3 == 3);
|
|
||||||
|
|
||||||
cout << "endian integer tests" << endl;
|
|
||||||
cout << "compute\n";
|
|
||||||
b3 = b1 + 5;
|
|
||||||
cout << "test\n";
|
|
||||||
BOOST_TEST(b3 == 6);
|
|
||||||
cout << "compute\n";
|
|
||||||
b3 = b1 + b2;
|
|
||||||
cout << "test\n";
|
|
||||||
BOOST_TEST(b3 == 3);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ::boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
{ // Use case 1 - Conversion functions
|
||||||
|
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
uint32_t count; // big endian
|
||||||
|
int32_t value; // big endian
|
||||||
|
};
|
||||||
|
|
||||||
|
Record rec;
|
||||||
|
|
||||||
|
read(&rec, sizeof(Record));
|
||||||
|
|
||||||
|
uint32_t count = big(rec.count);
|
||||||
|
int32_t value = big(rec.value);
|
||||||
|
|
||||||
|
++count;
|
||||||
|
value += fee;
|
||||||
|
|
||||||
|
rec.count = big(count);
|
||||||
|
rec.value = big(value);
|
||||||
|
|
||||||
|
write(&rec, sizeof(Record));
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // Use case 2 - Endian buffer types
|
||||||
|
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
big_ubuf32_t count; // big endian
|
||||||
|
big_buf32_t value; // big endian
|
||||||
|
};
|
||||||
|
|
||||||
|
Record rec;
|
||||||
|
|
||||||
|
read(&rec, sizeof(Record));
|
||||||
|
|
||||||
|
uint32_t count = rec.count.value();
|
||||||
|
int32_t value = rec.value.value();
|
||||||
|
|
||||||
|
++count;
|
||||||
|
value += fee;
|
||||||
|
|
||||||
|
rec.count = count;
|
||||||
|
rec.value = value;
|
||||||
|
|
||||||
|
write(&rec, sizeof(Record));
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // Use case 3a - Endian arithmetic types
|
||||||
|
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
big_uint32_t count; // big endian
|
||||||
|
big_int32_t value; // big endian
|
||||||
|
};
|
||||||
|
|
||||||
|
Record rec;
|
||||||
|
|
||||||
|
read(&rec, sizeof(Record));
|
||||||
|
|
||||||
|
++rec.count;
|
||||||
|
rec.value += fee;
|
||||||
|
|
||||||
|
write(&rec, sizeof(Record));
|
||||||
|
}
|
||||||
|
|
||||||
|
{ // Use case 3b - Endian arithmetic types
|
||||||
|
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
big_uint32_t count; // big endian
|
||||||
|
big_int32_t value; // big endian
|
||||||
|
};
|
||||||
|
|
||||||
|
Record rec;
|
||||||
|
|
||||||
|
read(&rec, sizeof(Record));
|
||||||
|
|
||||||
|
uint32_t count = rec.count;
|
||||||
|
int32_t value = rec.value;
|
||||||
|
|
||||||
|
++count;
|
||||||
|
value += fee;
|
||||||
|
|
||||||
|
rec.count = count;
|
||||||
|
rec.value = value;
|
||||||
|
|
||||||
|
write(&rec, sizeof(Record));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recommended approach when conversion time is not a concern
|
||||||
|
//
|
||||||
|
// Conversion time is not a concert with this application because the minimum
|
||||||
|
// possible number of conversions is performed and because I/O time will be
|
||||||
|
// much greater than conversion time.
|
||||||
|
|
||||||
|
{
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
big_uint32_t count; // big endian
|
||||||
|
big_int32_t value; // big endian
|
||||||
|
};
|
||||||
|
|
||||||
|
Record rec;
|
||||||
|
|
||||||
|
read(&rec, sizeof(Record));
|
||||||
|
|
||||||
|
++rec.count;
|
||||||
|
rec.value += fee;
|
||||||
|
|
||||||
|
write(&rec, sizeof(Record));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recommended approach when conversion time is a concern
|
||||||
|
//
|
||||||
|
// Conversion time is a concert with this application because (1) any conversions
|
||||||
|
// performed in the loop will consume a great deal of time and because (2)
|
||||||
|
// computation time will be much greater than I/O time.
|
||||||
|
|
||||||
|
{
|
||||||
|
struct Record
|
||||||
|
{
|
||||||
|
big_uint32_t count; // big endian
|
||||||
|
big_int32_t value; // big endian
|
||||||
|
};
|
||||||
|
|
||||||
|
Record rec;
|
||||||
|
|
||||||
|
read(&rec, sizeof(Record));
|
||||||
|
|
||||||
|
uint32_t count = rec.count;
|
||||||
|
int32_t value = rec.value;
|
||||||
|
|
||||||
|
for (long long i = 0; i < several_gazillion; ++i) // (1)
|
||||||
|
{
|
||||||
|
... immensely complex computation using rec variables many times // (2)
|
||||||
|
}
|
||||||
|
|
||||||
|
rec.count = count;
|
||||||
|
rec.value = value;
|
||||||
|
|
||||||
|
write(&rec, sizeof(Record));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@@ -383,13 +383,13 @@ namespace endian
|
|||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "big, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
std::cout << "big, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
||||||
# endif
|
# endif
|
||||||
this->m_value = ::boost::endian::big_endian_value(val);
|
this->m_value = ::boost::endian::native_to_big(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
this->m_value = ::boost::endian::big_endian_value(val);
|
this->m_value = ::boost::endian::native_to_big(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
|
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
|
||||||
@@ -413,12 +413,12 @@ namespace endian
|
|||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "little, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
std::cout << "little, aligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
||||||
# endif
|
# endif
|
||||||
this->m_value = ::boost::endian::little_endian_value(val);
|
this->m_value = ::boost::endian::native_to_little(val);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
this->m_value = ::boost::endian::little_endian_value(val);
|
this->m_value = ::boost::endian::native_to_little(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
|
operator value_type() const BOOST_NOEXCEPT { return this->value(); }
|
||||||
|
@@ -516,27 +516,27 @@ namespace endian
|
|||||||
std::cout << "big, aligned, " << n_bits
|
std::cout << "big, aligned, " << n_bits
|
||||||
<< "-bits, construct(" << val << ")\n";
|
<< "-bits, construct(" << val << ")\n";
|
||||||
# endif
|
# endif
|
||||||
m_value = ::boost::endian::big_endian_value(val);
|
m_value = ::boost::endian::native_to_big(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_value = ::boost::endian::big_endian_value(val);
|
m_value = ::boost::endian::native_to_big(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
//operator value_type() const BOOST_NOEXCEPT
|
//operator value_type() const BOOST_NOEXCEPT
|
||||||
//{
|
//{
|
||||||
// return ::boost::endian::big_endian_value(m_value);
|
// return ::boost::endian::big_to_native(m_value);
|
||||||
//}
|
//}
|
||||||
value_type value() const BOOST_NOEXCEPT
|
value_type value() const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "big, aligned, " << n_bits << "-bits, convert("
|
std::cout << "big, aligned, " << n_bits << "-bits, convert("
|
||||||
<< ::boost::endian::big_endian_value(m_value) << ")\n";
|
<< ::boost::endian::big_to_native(m_value) << ")\n";
|
||||||
# endif
|
# endif
|
||||||
return ::boost::endian::big_endian_value(m_value);
|
return ::boost::endian::big_to_native(m_value);
|
||||||
}
|
}
|
||||||
const char* data() const BOOST_NOEXCEPT
|
const char* data() const BOOST_NOEXCEPT
|
||||||
{return reinterpret_cast<const char*>(&m_value);}
|
{return reinterpret_cast<const char*>(&m_value);}
|
||||||
@@ -561,13 +561,13 @@ namespace endian
|
|||||||
std::cout << "little, aligned, " << n_bits
|
std::cout << "little, aligned, " << n_bits
|
||||||
<< "-bits, construct(" << val << ")\n";
|
<< "-bits, construct(" << val << ")\n";
|
||||||
# endif
|
# endif
|
||||||
m_value = ::boost::endian::little_endian_value(val);
|
m_value = ::boost::endian::native_to_little(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_value = ::boost::endian::little_endian_value(val);
|
m_value = ::boost::endian::native_to_little(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
value_type value() const BOOST_NOEXCEPT
|
value_type value() const BOOST_NOEXCEPT
|
||||||
@@ -575,9 +575,9 @@ namespace endian
|
|||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "little, aligned, " << n_bits << "-bits, convert("
|
std::cout << "little, aligned, " << n_bits << "-bits, convert("
|
||||||
<< ::boost::endian::little_endian_value(m_value) << ")\n";
|
<< ::boost::endian::little_to_native(m_value) << ")\n";
|
||||||
# endif
|
# endif
|
||||||
return ::boost::endian::little_endian_value(m_value);
|
return ::boost::endian::little_to_native(m_value);
|
||||||
}
|
}
|
||||||
const char* data() const BOOST_NOEXCEPT
|
const char* data() const BOOST_NOEXCEPT
|
||||||
{return reinterpret_cast<const char*>(&m_value);}
|
{return reinterpret_cast<const char*>(&m_value);}
|
||||||
|
@@ -72,6 +72,9 @@ namespace endian
|
|||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT;
|
inline Reversible native_to_big(Reversible x) BOOST_NOEXCEPT;
|
||||||
// Returns: x if native endian order is big, otherwise reverse_endianness(x)
|
// Returns: x if native endian order is big, otherwise reverse_endianness(x)
|
||||||
|
template <class Reversible >
|
||||||
|
inline Reversible reverse_unless_native_big(Reversible x) BOOST_NOEXCEPT;
|
||||||
|
// Returns: x if native endian order is big, otherwise reverse_endianness(x)
|
||||||
|
|
||||||
// reverse byte order unless native endianness is little
|
// reverse byte order unless native endianness is little
|
||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
@@ -80,6 +83,9 @@ namespace endian
|
|||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT;
|
inline Reversible native_to_little(Reversible x) BOOST_NOEXCEPT;
|
||||||
// Returns: x if native endian order is little, otherwise reverse_endianness(x)
|
// Returns: x if native endian order is little, otherwise reverse_endianness(x)
|
||||||
|
template <class Reversible >
|
||||||
|
inline Reversible reverse_unless_native_little(Reversible x) BOOST_NOEXCEPT;
|
||||||
|
// Returns: x if native endian order is little, otherwise reverse_endianness(x)
|
||||||
|
|
||||||
// generic conditional reverse byte order
|
// generic conditional reverse byte order
|
||||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||||
@@ -141,6 +147,9 @@ namespace endian
|
|||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT;
|
inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT;
|
||||||
// Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x)
|
// Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x)
|
||||||
|
template <class Reversible>
|
||||||
|
inline void reverse_in_place_unless_native_big(Reversible& x) BOOST_NOEXCEPT;
|
||||||
|
// Effects: none if native byte-order is big, otherwise reverse_endianness_in_place(x)
|
||||||
|
|
||||||
// reverse in place unless native endianness is little
|
// reverse in place unless native endianness is little
|
||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
@@ -149,6 +158,9 @@ namespace endian
|
|||||||
template <class Reversible>
|
template <class Reversible>
|
||||||
inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT;
|
inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT;
|
||||||
// Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x);
|
// Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x);
|
||||||
|
template <class Reversible>
|
||||||
|
inline void reverse_in_place_unless_native_little(Reversible& x) BOOST_NOEXCEPT;
|
||||||
|
// Effects: none if native byte-order is little, otherwise reverse_endianness_in_place(x);
|
||||||
|
|
||||||
// generic conditional reverse in place
|
// generic conditional reverse in place
|
||||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class Reversible>
|
||||||
@@ -264,7 +276,7 @@ namespace endian
|
|||||||
// suggested by Mathias Gaunard. Primary motivation for inclusion is to have an
|
// suggested by Mathias Gaunard. Primary motivation for inclusion is to have an
|
||||||
// independent implementation to test against. Secondary motivation is use by
|
// independent implementation to test against. Secondary motivation is use by
|
||||||
// floating-point reverse_endianness, but that use is likely to be replace by a
|
// floating-point reverse_endianness, but that use is likely to be replace by a
|
||||||
// more tailored floating-point algorithm.
|
// more tailored floating-point implementation.
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T std_reverse_endianness(T x) BOOST_NOEXCEPT
|
inline T std_reverse_endianness(T x) BOOST_NOEXCEPT
|
||||||
@@ -275,6 +287,16 @@ namespace endian
|
|||||||
reinterpret_cast<char*>(&tmp) + sizeof(T));
|
reinterpret_cast<char*>(&tmp) + sizeof(T));
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// conditional unaligned reverse copy, patterned after std::reverse_copy
|
||||||
|
template <class T>
|
||||||
|
inline void big_reverse_copy(T from, char* to) BOOST_NOEXCEPT;
|
||||||
|
template <class T>
|
||||||
|
inline void big_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT;
|
||||||
|
template <class T>
|
||||||
|
inline void little_reverse_copy(T from, char* to) BOOST_NOEXCEPT;
|
||||||
|
template <class T>
|
||||||
|
inline void little_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT;
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
inline float reverse_endianness(float x) BOOST_NOEXCEPT
|
inline float reverse_endianness(float x) BOOST_NOEXCEPT
|
||||||
@@ -313,6 +335,16 @@ namespace endian
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Reversible >
|
||||||
|
inline Reversible reverse_unless_native_big(Reversible x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
|
return x;
|
||||||
|
# else
|
||||||
|
return reverse_endianness(x);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
template <class Reversible >
|
template <class Reversible >
|
||||||
inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT
|
inline Reversible little_to_native(Reversible x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
@@ -333,6 +365,16 @@ namespace endian
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class Reversible >
|
||||||
|
inline Reversible reverse_unless_native_little(Reversible x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
# ifdef BOOST_LITTLE_ENDIAN
|
||||||
|
return x;
|
||||||
|
# else
|
||||||
|
return reverse_endianness(x);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
// Primary template and specializations to support reverse_endianness().
|
// Primary template and specializations to support reverse_endianness().
|
||||||
@@ -408,7 +450,18 @@ namespace endian
|
|||||||
inline void native_to_big_in_place(Reversible&) BOOST_NOEXCEPT {}
|
inline void native_to_big_in_place(Reversible&) BOOST_NOEXCEPT {}
|
||||||
# else
|
# else
|
||||||
inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT
|
inline void native_to_big_in_place(Reversible& x) BOOST_NOEXCEPT
|
||||||
{ reverse_endianness_in_place(x); }
|
{
|
||||||
|
reverse_endianness_in_place(x);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
template <class Reversible>
|
||||||
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
|
inline void reverse_in_place_unless_native_big(Reversible&) BOOST_NOEXCEPT {}
|
||||||
|
# else
|
||||||
|
inline void reverse_in_place_unless_native_big(Reversible& x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
reverse_endianness_in_place(x);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
// reverse in place unless native endianness is little
|
// reverse in place unless native endianness is little
|
||||||
@@ -426,7 +479,18 @@ namespace endian
|
|||||||
inline void native_to_little_in_place(Reversible&) BOOST_NOEXCEPT {}
|
inline void native_to_little_in_place(Reversible&) BOOST_NOEXCEPT {}
|
||||||
# else
|
# else
|
||||||
inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT
|
inline void native_to_little_in_place(Reversible& x) BOOST_NOEXCEPT
|
||||||
{ reverse_endianness_in_place(x); }
|
{
|
||||||
|
reverse_endianness_in_place(x);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
template <class Reversible>
|
||||||
|
# ifdef BOOST_LITTLE_ENDIAN
|
||||||
|
inline void reverse_in_place_unless_native_little(Reversible&) BOOST_NOEXCEPT {}
|
||||||
|
# else
|
||||||
|
inline void reverse_in_place_unless_native_little(Reversible& x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
reverse_endianness_in_place(x);
|
||||||
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
@@ -467,6 +531,59 @@ namespace endian
|
|||||||
reverse_endianness_in_place(x);
|
reverse_endianness_in_place(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
// general reverse_value function template implementation approach using std::reverse
|
||||||
|
// suggested by Mathias Gaunard
|
||||||
|
template <class T>
|
||||||
|
inline T reverse_value(T x) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
T tmp(x);
|
||||||
|
std::reverse(
|
||||||
|
reinterpret_cast<char*>(&tmp),
|
||||||
|
reinterpret_cast<char*>(&tmp) + sizeof(T));
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
inline void big_reverse_copy(T from, char* to) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
|
std::memcpy(to, reinterpret_cast<const char*>(&from), sizeof(T));
|
||||||
|
# else
|
||||||
|
std::reverse_copy(reinterpret_cast<const char*>(&from),
|
||||||
|
reinterpret_cast<const char*>(&from) + sizeof(T), to);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
inline void big_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
|
std::memcpy(reinterpret_cast<char*>(&to), from, sizeof(T));
|
||||||
|
# else
|
||||||
|
std::reverse_copy(from, from + sizeof(T), reinterpret_cast<char*>(&to));
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
inline void little_reverse_copy(T from, char* to) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
# ifdef BOOST_LITTLE_ENDIAN
|
||||||
|
std::memcpy(to, reinterpret_cast<const char*>(&from), sizeof(T));
|
||||||
|
# else
|
||||||
|
std::reverse_copy(reinterpret_cast<const char*>(&from),
|
||||||
|
reinterpret_cast<const char*>(&from) + sizeof(T), to);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
template <class T>
|
||||||
|
inline void little_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
# ifdef BOOST_LITTLE_ENDIAN
|
||||||
|
std::memcpy(reinterpret_cast<char*>(&to), from, sizeof(T));
|
||||||
|
# else
|
||||||
|
std::reverse_copy(from, from + sizeof(T), reinterpret_cast<char*>(&to));
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
} // namespace detail
|
||||||
} // namespace endian
|
} // namespace endian
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
9
name_changes.sed
Normal file
9
name_changes.sed
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# invoke: sed -r -i -f <path-to-this-file> <files-to-change...>
|
||||||
|
|
||||||
|
# name changes in arithmetic.hpp
|
||||||
|
s/(big|little|native)_(int|uint|float)(8|16|24|32|40|48|56|64)_t/\1_\2\3_ut/g
|
||||||
|
s/(big|little|native)_align_(int|uint|float)(8|16|24|32|40|48|56|64)_t/\1_\2\3_t/g
|
||||||
|
|
||||||
|
# name changes in conversion.hpp
|
||||||
|
s/(big|little)_endian\(/reverse_in_place_unless_native_\1(/g
|
||||||
|
s/(big|little)_endian_value\(/reverse_unless_native_\1(/g
|
@@ -6,6 +6,7 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#define _SCL_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <boost/endian/conversion.hpp>
|
#include <boost/endian/conversion.hpp>
|
||||||
|
@@ -29,15 +29,15 @@ int cpp_main(int, char *[])
|
|||||||
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
|
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
|
||||||
|
|
||||||
cout << " construct" << endl;
|
cout << " construct" << endl;
|
||||||
bel::big_buf32_t x(1122334455);
|
bel::big_int32_buf_t x(1122334455);
|
||||||
|
|
||||||
cout << " assign from built-in integer" << endl;
|
cout << " assign from built-in integer" << endl;
|
||||||
x = 1234567890;
|
x = 1234567890;
|
||||||
|
|
||||||
cout << " operator==(buffer, built-in)" << endl;
|
cout << " operator==(buffer, built-in)" << endl;
|
||||||
// bool b1(x == 1234567890);
|
bool b1(x.value() == 1234567890);
|
||||||
|
BOOST_TEST(b1);
|
||||||
|
|
||||||
// BOOST_TEST(x == 1234567890);
|
|
||||||
cout << " done" << endl;
|
cout << " done" << endl;
|
||||||
|
|
||||||
return ::boost::report_errors();
|
return ::boost::report_errors();
|
||||||
|
@@ -604,25 +604,25 @@ namespace
|
|||||||
{
|
{
|
||||||
// aligned floating point types
|
// aligned floating point types
|
||||||
float big_float32_expected = (std::numeric_limits<float>::max) ();
|
float big_float32_expected = (std::numeric_limits<float>::max) ();
|
||||||
boost::endian::big_endian(big_float32_expected);
|
boost::endian::native_to_big_in_place(big_float32_expected);
|
||||||
big_float32_t big_float32((std::numeric_limits<float>::max) ());
|
big_float32_t big_float32((std::numeric_limits<float>::max) ());
|
||||||
VERIFY(std::memcmp(big_float32.data(),
|
VERIFY(std::memcmp(big_float32.data(),
|
||||||
reinterpret_cast<const char*>(&big_float32_expected), sizeof(float)) == 0);
|
reinterpret_cast<const char*>(&big_float32_expected), sizeof(float)) == 0);
|
||||||
|
|
||||||
float little_float32_expected = (std::numeric_limits<float>::max) ();
|
float little_float32_expected = (std::numeric_limits<float>::max) ();
|
||||||
boost::endian::little_endian(little_float32_expected);
|
boost::endian::native_to_little_in_place(little_float32_expected);
|
||||||
little_float32_t little_float32((std::numeric_limits<float>::max) ());
|
little_float32_t little_float32((std::numeric_limits<float>::max) ());
|
||||||
VERIFY(std::memcmp(little_float32.data(),
|
VERIFY(std::memcmp(little_float32.data(),
|
||||||
reinterpret_cast<const char*>(&little_float32_expected), sizeof(float)) == 0);
|
reinterpret_cast<const char*>(&little_float32_expected), sizeof(float)) == 0);
|
||||||
|
|
||||||
double big_float64_expected = (std::numeric_limits<double>::max) ();
|
double big_float64_expected = (std::numeric_limits<double>::max) ();
|
||||||
boost::endian::big_endian(big_float64_expected);
|
boost::endian::native_to_big_in_place(big_float64_expected);
|
||||||
big_float64_t big_float64((std::numeric_limits<double>::max) ());
|
big_float64_t big_float64((std::numeric_limits<double>::max) ());
|
||||||
VERIFY(std::memcmp(big_float64.data(),
|
VERIFY(std::memcmp(big_float64.data(),
|
||||||
reinterpret_cast<const char*>(&big_float64_expected), sizeof(double)) == 0);
|
reinterpret_cast<const char*>(&big_float64_expected), sizeof(double)) == 0);
|
||||||
|
|
||||||
double little_float64_expected = (std::numeric_limits<double>::max) ();
|
double little_float64_expected = (std::numeric_limits<double>::max) ();
|
||||||
boost::endian::little_endian(little_float64_expected);
|
boost::endian::native_to_little_in_place(little_float64_expected);
|
||||||
little_float64_t little_float64((std::numeric_limits<double>::max) ());
|
little_float64_t little_float64((std::numeric_limits<double>::max) ());
|
||||||
VERIFY(std::memcmp(little_float64.data(),
|
VERIFY(std::memcmp(little_float64.data(),
|
||||||
reinterpret_cast<const char*>(&little_float64_expected), sizeof(double)) == 0);
|
reinterpret_cast<const char*>(&little_float64_expected), sizeof(double)) == 0);
|
||||||
@@ -639,25 +639,25 @@ namespace
|
|||||||
|
|
||||||
// unaligned floating point types
|
// unaligned floating point types
|
||||||
float big_float32un_expected = (std::numeric_limits<float>::max) ();
|
float big_float32un_expected = (std::numeric_limits<float>::max) ();
|
||||||
boost::endian::big_endian(big_float32un_expected);
|
boost::endian::native_to_big_in_place(big_float32un_expected);
|
||||||
big_float32_ut big_float32un((std::numeric_limits<float>::max) ());
|
big_float32_ut big_float32un((std::numeric_limits<float>::max) ());
|
||||||
VERIFY(std::memcmp(big_float32un.data(),
|
VERIFY(std::memcmp(big_float32un.data(),
|
||||||
reinterpret_cast<const char*>(&big_float32un_expected), sizeof(float)) == 0);
|
reinterpret_cast<const char*>(&big_float32un_expected), sizeof(float)) == 0);
|
||||||
|
|
||||||
float little_float32un_expected = (std::numeric_limits<float>::max) ();
|
float little_float32un_expected = (std::numeric_limits<float>::max) ();
|
||||||
boost::endian::little_endian(little_float32un_expected);
|
boost::endian::native_to_little_in_place(little_float32un_expected);
|
||||||
little_float32_ut little_float32un((std::numeric_limits<float>::max) ());
|
little_float32_ut little_float32un((std::numeric_limits<float>::max) ());
|
||||||
VERIFY(std::memcmp(little_float32un.data(),
|
VERIFY(std::memcmp(little_float32un.data(),
|
||||||
reinterpret_cast<const char*>(&little_float32un_expected), sizeof(float)) == 0);
|
reinterpret_cast<const char*>(&little_float32un_expected), sizeof(float)) == 0);
|
||||||
|
|
||||||
double big_float64un_expected = (std::numeric_limits<double>::max) ();
|
double big_float64un_expected = (std::numeric_limits<double>::max) ();
|
||||||
boost::endian::big_endian(big_float64un_expected);
|
boost::endian::native_to_big_in_place(big_float64un_expected);
|
||||||
big_float64_ut big_float64un((std::numeric_limits<double>::max) ());
|
big_float64_ut big_float64un((std::numeric_limits<double>::max) ());
|
||||||
VERIFY(std::memcmp(big_float64un.data(),
|
VERIFY(std::memcmp(big_float64un.data(),
|
||||||
reinterpret_cast<const char*>(&big_float64un_expected), sizeof(double)) == 0);
|
reinterpret_cast<const char*>(&big_float64un_expected), sizeof(double)) == 0);
|
||||||
|
|
||||||
double little_float64un_expected = (std::numeric_limits<double>::max) ();
|
double little_float64un_expected = (std::numeric_limits<double>::max) ();
|
||||||
boost::endian::little_endian(little_float64un_expected);
|
boost::endian::native_to_little_in_place(little_float64un_expected);
|
||||||
little_float64_ut little_float64un((std::numeric_limits<double>::max) ());
|
little_float64_ut little_float64un((std::numeric_limits<double>::max) ());
|
||||||
VERIFY(std::memcmp(little_float64un.data(),
|
VERIFY(std::memcmp(little_float64un.data(),
|
||||||
reinterpret_cast<const char*>(&little_float64un_expected), sizeof(double)) == 0);
|
reinterpret_cast<const char*>(&little_float64un_expected), sizeof(double)) == 0);
|
||||||
|
@@ -101,14 +101,14 @@ namespace
|
|||||||
// cout << "***************Endian conversion approach...\n";
|
// cout << "***************Endian conversion approach...\n";
|
||||||
T x(0);
|
T x(0);
|
||||||
boost::timer::cpu_timer t;
|
boost::timer::cpu_timer t;
|
||||||
big_endian(x);
|
native_to_big_in_place(x);
|
||||||
for (uint64_t i = 0; i < n; ++i)
|
for (uint64_t i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
x += static_cast<T>(i);
|
x += static_cast<T>(i);
|
||||||
}
|
}
|
||||||
big_endian(x);
|
big_to_native_in_place(x);
|
||||||
t.stop();
|
t.stop();
|
||||||
big_endian(x);
|
native_to_big_in_place(x);
|
||||||
if (x != total)
|
if (x != total)
|
||||||
throw std::logic_error("integer approach total != conversion approach total");
|
throw std::logic_error("integer approach total != conversion approach total");
|
||||||
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
|
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
|
||||||
|
@@ -17,8 +17,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark\benc
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "converter_test", "converter_test\converter_test.vcxproj", "{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "converter_test", "converter_test\converter_test.vcxproj", "{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pair_test", "pair_test\pair_test.vcxproj", "{5223CCD9-F1D4-4778-9BFD-242533DFE380}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udt_conversion_example", "udt_conversion_example\udt_conversion_example.vcxproj", "{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udt_conversion_example", "udt_conversion_example\udt_conversion_example.vcxproj", "{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "speed_test", "speed_test\speed_test.vcxproj", "{5407AF29-59E9-4DE2-9939-F067576F7868}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "speed_test", "speed_test\speed_test.vcxproj", "{5407AF29-59E9-4DE2-9939-F067576F7868}"
|
||||||
@@ -89,14 +87,6 @@ Global
|
|||||||
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|Win32.Build.0 = Release|Win32
|
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|Win32.Build.0 = Release|Win32
|
||||||
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|x64.ActiveCfg = Release|x64
|
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|x64.ActiveCfg = Release|x64
|
||||||
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|x64.Build.0 = Release|x64
|
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|x64.Build.0 = Release|x64
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{5223CCD9-F1D4-4778-9BFD-242533DFE380}.Release|x64.Build.0 = Release|x64
|
|
||||||
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|Win32.ActiveCfg = Debug|Win32
|
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|Win32.Build.0 = Debug|Win32
|
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|x64.ActiveCfg = Debug|x64
|
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
@@ -1,151 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{5223CCD9-F1D4-4778-9BFD-242533DFE380}</ProjectGuid>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<RootNamespace>pair_test</RootNamespace>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\common.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\common.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\common.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
<Import Project="..\common.props" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<LinkIncremental>true</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<LinkIncremental>false</LinkIncremental>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<PrecompiledHeader>
|
|
||||||
</PrecompiledHeader>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="..\..\pair_test.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@@ -1,87 +0,0 @@
|
|||||||
// pair_test.cpp ---------------------------------------------------------------------//
|
|
||||||
|
|
||||||
// Copyright Beman Dawes 2013
|
|
||||||
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// http://www.boost.org/LICENSE_1_0.txt
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
#include <boost/endian/detail/disable_warnings.hpp>
|
|
||||||
|
|
||||||
#include <boost/endian/std_pair.hpp>
|
|
||||||
#include <boost/detail/lightweight_main.hpp>
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
using namespace boost::endian;
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
using boost::int16_t;
|
|
||||||
using boost::uint16_t;
|
|
||||||
using boost::int32_t;
|
|
||||||
using boost::uint32_t;
|
|
||||||
using boost::int64_t;
|
|
||||||
using boost::uint64_t;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
typedef std::pair<int16_t, int32_t> MyPair;
|
|
||||||
|
|
||||||
template <class OS>
|
|
||||||
OS& operator<<(OS& os, MyPair my)
|
|
||||||
{
|
|
||||||
const char* first = reinterpret_cast<const char*>(&my.first);
|
|
||||||
const char* second = reinterpret_cast<const char*>(&my.second);
|
|
||||||
|
|
||||||
os << std::hex
|
|
||||||
<< int(*first) << ' ' << int(*(first+1)) << ", "
|
|
||||||
<< int(*second) << ' ' << int(*(second+1)) << ' '
|
|
||||||
<< int(*(second+2)) << ' ' << int(*(second+3))
|
|
||||||
<< std::dec << std::endl;
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // unnamed namespace
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
int cpp_main(int, char * [])
|
|
||||||
{
|
|
||||||
cout << "pair_test" << endl << endl;
|
|
||||||
|
|
||||||
MyPair x(0x0102, 0x01020304);
|
|
||||||
MyPair y(big_endian_value(x));
|
|
||||||
MyPair z(little_endian_value(x));
|
|
||||||
|
|
||||||
cout << "native: " << x;
|
|
||||||
cout << " big: " << y;
|
|
||||||
cout << "little: " << z << endl;
|
|
||||||
|
|
||||||
big_endian(x);
|
|
||||||
cout << " big: " << x;
|
|
||||||
reverse(x);
|
|
||||||
little_endian(x);
|
|
||||||
cout << "little: " << x << endl;
|
|
||||||
|
|
||||||
convert(x, order::little, order::native);
|
|
||||||
y = MyPair(0, 0);
|
|
||||||
y = convert_value(x, order::native, order::big);
|
|
||||||
z = x;
|
|
||||||
little_endian(z);
|
|
||||||
cout << "native: " << x;
|
|
||||||
cout << " big: " << y;
|
|
||||||
cout << "little: " << z << endl;
|
|
||||||
|
|
||||||
cout << " big: " << y;
|
|
||||||
convert<order::big, order::little>(y);
|
|
||||||
cout << "little: " << y << endl;
|
|
||||||
convert<order::little, order::big>(y);
|
|
||||||
|
|
||||||
return ::boost::report_errors();
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
|
@@ -99,60 +99,60 @@ namespace
|
|||||||
void test_big_int16()
|
void test_big_int16()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>16-bit aligned big endian</td>";
|
cout << "<tr><td>16-bit aligned big endian</td>";
|
||||||
time<int16_t, big_int16_t>(user::return_x_big_int16);
|
time<int16_t, big_int16_ut>(user::return_x_big_int16);
|
||||||
time<int16_t, big_int16_t>(user::return_x_value_big_int16);
|
time<int16_t, big_int16_ut>(user::return_x_value_big_int16);
|
||||||
time<int16_t, big_int16_t>(user::return_x_in_place_big_int16);
|
time<int16_t, big_int16_ut>(user::return_x_in_place_big_int16);
|
||||||
time<int16_t, big_int16_t>(user::return_x_big_int16);
|
time<int16_t, big_int16_ut>(user::return_x_big_int16);
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_little_int16()
|
void test_little_int16()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>16-bit aligned little endian</td>";
|
cout << "<tr><td>16-bit aligned little endian</td>";
|
||||||
time<int16_t, little_int16_t>(user::return_x_little_int16);
|
time<int16_t, little_int16_ut>(user::return_x_little_int16);
|
||||||
time<int16_t, little_int16_t>(user::return_x_value_little_int16);
|
time<int16_t, little_int16_ut>(user::return_x_value_little_int16);
|
||||||
time<int16_t, little_int16_t>(user::return_x_in_place_little_int16);
|
time<int16_t, little_int16_ut>(user::return_x_in_place_little_int16);
|
||||||
time<int16_t, little_int16_t>(user::return_x_little_int16);
|
time<int16_t, little_int16_ut>(user::return_x_little_int16);
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_big_int32()
|
void test_big_int32()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>32-bit aligned big endian</td>";
|
cout << "<tr><td>32-bit aligned big endian</td>";
|
||||||
time<int32_t, big_int32_t>(user::return_x_big_int32);
|
time<int32_t, big_int32_ut>(user::return_x_big_int32);
|
||||||
time<int32_t, big_int32_t>(user::return_x_value_big_int32);
|
time<int32_t, big_int32_ut>(user::return_x_value_big_int32);
|
||||||
time<int32_t, big_int32_t>(user::return_x_in_place_big_int32);
|
time<int32_t, big_int32_ut>(user::return_x_in_place_big_int32);
|
||||||
time<int32_t, big_int32_t>(user::return_x_big_int32);
|
time<int32_t, big_int32_ut>(user::return_x_big_int32);
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_little_int32()
|
void test_little_int32()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>32-bit aligned little endian</td>";
|
cout << "<tr><td>32-bit aligned little endian</td>";
|
||||||
time<int32_t, little_int32_t>(user::return_x_little_int32);
|
time<int32_t, little_int32_ut>(user::return_x_little_int32);
|
||||||
time<int32_t, little_int32_t>(user::return_x_value_little_int32);
|
time<int32_t, little_int32_ut>(user::return_x_value_little_int32);
|
||||||
time<int32_t, little_int32_t>(user::return_x_in_place_little_int32);
|
time<int32_t, little_int32_ut>(user::return_x_in_place_little_int32);
|
||||||
time<int32_t, little_int32_t>(user::return_x_little_int32);
|
time<int32_t, little_int32_ut>(user::return_x_little_int32);
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_big_int64()
|
void test_big_int64()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>64-bit aligned big endian</td>";
|
cout << "<tr><td>64-bit aligned big endian</td>";
|
||||||
time<int64_t, big_int64_t>(user::return_x_big_int64);
|
time<int64_t, big_int64_ut>(user::return_x_big_int64);
|
||||||
time<int64_t, big_int64_t>(user::return_x_value_big_int64);
|
time<int64_t, big_int64_ut>(user::return_x_value_big_int64);
|
||||||
time<int64_t, big_int64_t>(user::return_x_in_place_big_int64);
|
time<int64_t, big_int64_ut>(user::return_x_in_place_big_int64);
|
||||||
time<int64_t, big_int64_t>(user::return_x_big_int64);
|
time<int64_t, big_int64_ut>(user::return_x_big_int64);
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_little_int64()
|
void test_little_int64()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>64-bit aligned little endian</td>";
|
cout << "<tr><td>64-bit aligned little endian</td>";
|
||||||
time<int64_t, little_int64_t>(user::return_x_little_int64);
|
time<int64_t, little_int64_ut>(user::return_x_little_int64);
|
||||||
time<int64_t, little_int64_t>(user::return_x_value_little_int64);
|
time<int64_t, little_int64_ut>(user::return_x_value_little_int64);
|
||||||
time<int64_t, little_int64_t>(user::return_x_in_place_little_int64);
|
time<int64_t, little_int64_ut>(user::return_x_in_place_little_int64);
|
||||||
time<int64_t, little_int64_t>(user::return_x_little_int64);
|
time<int64_t, little_int64_ut>(user::return_x_little_int64);
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,31 +20,43 @@
|
|||||||
namespace user
|
namespace user
|
||||||
{
|
{
|
||||||
|
|
||||||
int16_t return_x_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT {return x;}
|
int16_t return_x_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT {return x;}
|
||||||
int16_t return_x_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT {return x;}
|
int16_t return_x_little_int16(int16_t x, little_int16_ut) 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_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT
|
||||||
int16_t return_x_value_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT {return little_endian_value(x);}
|
{return reverse_unless_native_big(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_value_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT
|
||||||
int16_t return_x_in_place_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT {little_endian(x);return x;}
|
{return reverse_unless_native_little(x);}
|
||||||
int16_t return_y_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT {return y;}
|
int16_t return_x_in_place_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT
|
||||||
int16_t return_y_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT {return y;}
|
{reverse_in_place_unless_native_big(x);return x;}
|
||||||
|
int16_t return_x_in_place_little_int16(int16_t x, little_int16_ut) BOOST_NOEXCEPT
|
||||||
|
{reverse_in_place_unless_native_little(x);return x;}
|
||||||
|
int16_t return_y_big_int16(int16_t x, big_int16_ut y) BOOST_NOEXCEPT {return y;}
|
||||||
|
int16_t return_y_little_int16(int16_t x, little_int16_ut 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_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT {return x;}
|
||||||
int32_t return_x_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT {return x;}
|
int32_t return_x_little_int32(int32_t x, little_int32_ut) 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_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT
|
||||||
int32_t return_x_value_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT {return little_endian_value(x);}
|
{return reverse_unless_native_big(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_value_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT
|
||||||
int32_t return_x_in_place_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT {little_endian(x);return x;}
|
{return reverse_unless_native_little(x);}
|
||||||
int32_t return_y_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT {return y;}
|
int32_t return_x_in_place_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT
|
||||||
int32_t return_y_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT {return y;}
|
{reverse_in_place_unless_native_big(x);return x;}
|
||||||
|
int32_t return_x_in_place_little_int32(int32_t x, little_int32_ut) BOOST_NOEXCEPT
|
||||||
|
{reverse_in_place_unless_native_little(x);return x;}
|
||||||
|
int32_t return_y_big_int32(int32_t x, big_int32_ut y) BOOST_NOEXCEPT {return y;}
|
||||||
|
int32_t return_y_little_int32(int32_t x, little_int32_ut 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_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT {return x;}
|
||||||
int64_t return_x_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT {return x;}
|
int64_t return_x_little_int64(int64_t x, little_int64_ut) 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_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT
|
||||||
int64_t return_x_value_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT {return little_endian_value(x);}
|
{return reverse_unless_native_big(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_value_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT
|
||||||
int64_t return_x_in_place_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT {little_endian(x);return x;}
|
{return reverse_unless_native_little(x);}
|
||||||
int64_t return_y_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT {return y;}
|
int64_t return_x_in_place_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT
|
||||||
int64_t return_y_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT {return y;}
|
{reverse_in_place_unless_native_big(x);return x;}
|
||||||
|
int64_t return_x_in_place_little_int64(int64_t x, little_int64_ut) BOOST_NOEXCEPT
|
||||||
|
{reverse_in_place_unless_native_little(x);return x;}
|
||||||
|
int64_t return_y_big_int64(int64_t x, big_int64_ut y) BOOST_NOEXCEPT {return y;}
|
||||||
|
int64_t return_y_little_int64(int64_t x, little_int64_ut y) BOOST_NOEXCEPT {return y;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -24,32 +24,32 @@ namespace user
|
|||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace boost::endian;
|
using namespace boost::endian;
|
||||||
|
|
||||||
int16_t return_x_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT;
|
int16_t return_x_big_int16(int16_t x, big_int16_ut y) BOOST_NOEXCEPT;
|
||||||
int16_t return_x_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
|
int16_t return_x_little_int16(int16_t x, little_int16_ut y) BOOST_NOEXCEPT;
|
||||||
int16_t return_x_value_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT;
|
int16_t return_x_value_big_int16(int16_t x, big_int16_ut) BOOST_NOEXCEPT;
|
||||||
int16_t return_x_value_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
|
int16_t return_x_value_little_int16(int16_t x, little_int16_ut 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_big_int16(int16_t x, big_int16_ut y) BOOST_NOEXCEPT;
|
||||||
int16_t return_x_in_place_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
|
int16_t return_x_in_place_little_int16(int16_t x, little_int16_ut y) BOOST_NOEXCEPT;
|
||||||
int16_t return_y_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT;
|
int16_t return_y_big_int16(int16_t x, big_int16_ut y) BOOST_NOEXCEPT;
|
||||||
int16_t return_y_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT;
|
int16_t return_y_little_int16(int16_t x, little_int16_ut y) BOOST_NOEXCEPT;
|
||||||
|
|
||||||
int32_t return_x_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT;
|
int32_t return_x_big_int32(int32_t x, big_int32_ut y) BOOST_NOEXCEPT;
|
||||||
int32_t return_x_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
|
int32_t return_x_little_int32(int32_t x, little_int32_ut y) BOOST_NOEXCEPT;
|
||||||
int32_t return_x_value_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT;
|
int32_t return_x_value_big_int32(int32_t x, big_int32_ut) BOOST_NOEXCEPT;
|
||||||
int32_t return_x_value_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
|
int32_t return_x_value_little_int32(int32_t x, little_int32_ut 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_big_int32(int32_t x, big_int32_ut y) BOOST_NOEXCEPT;
|
||||||
int32_t return_x_in_place_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
|
int32_t return_x_in_place_little_int32(int32_t x, little_int32_ut y) BOOST_NOEXCEPT;
|
||||||
int32_t return_y_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT;
|
int32_t return_y_big_int32(int32_t x, big_int32_ut y) BOOST_NOEXCEPT;
|
||||||
int32_t return_y_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT;
|
int32_t return_y_little_int32(int32_t x, little_int32_ut y) BOOST_NOEXCEPT;
|
||||||
|
|
||||||
int64_t return_x_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT;
|
int64_t return_x_big_int64(int64_t x, big_int64_ut y) BOOST_NOEXCEPT;
|
||||||
int64_t return_x_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
|
int64_t return_x_little_int64(int64_t x, little_int64_ut y) BOOST_NOEXCEPT;
|
||||||
int64_t return_x_value_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT;
|
int64_t return_x_value_big_int64(int64_t x, big_int64_ut) BOOST_NOEXCEPT;
|
||||||
int64_t return_x_value_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
|
int64_t return_x_value_little_int64(int64_t x, little_int64_ut 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_big_int64(int64_t x, big_int64_ut y) BOOST_NOEXCEPT;
|
||||||
int64_t return_x_in_place_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
|
int64_t return_x_in_place_little_int64(int64_t x, little_int64_ut y) BOOST_NOEXCEPT;
|
||||||
int64_t return_y_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT;
|
int64_t return_y_big_int64(int64_t x, big_int64_ut y) BOOST_NOEXCEPT;
|
||||||
int64_t return_y_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT;
|
int64_t return_y_little_int64(int64_t x, little_int64_ut y) BOOST_NOEXCEPT;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user