mirror of
https://github.com/boostorg/endian.git
synced 2025-08-01 13:34:39 +02:00
Remove "explicit" from Endian type constructors. Rationale: Having to write "cntr.insert(big_int32_t(value))" instead of "cntr.insert(value)" gets old fast when you are writing application code and the use case arises more or less continuously. Additionally, the use of an endian type is an implementation detail that should not leak into the application code that needs to create values of the type. Furthermore, the ambiguities that caused the constructors to be made explicit no longer occur; they were eliminated when BOOST_MINIMAL_INTEGER_COVER_OPERATORS was introduced to removed a dependency on boost/operators.hpp. If an ambiguity does arise, it is easy to clear via a static_cast or a function-style cast.
This commit is contained in:
@@ -76,7 +76,7 @@
|
|||||||
</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="../include/boost/endian/types.hpp">boost/endian/types.hpp</a>
|
||||||
provides integer and floating point binary types with explicit 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>
|
||||||
<p>These types provide portable byte-holders for integer data, independent of
|
<p>These types provide portable byte-holders for integer data, independent of
|
||||||
@@ -102,7 +102,7 @@ arithmetic operators are <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. An
|
||||||
explicit 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
|
||||||
binary file containing four byte big-endian and little-endian integers:</p>
|
binary file containing four byte big-endian and little-endian integers:</p>
|
||||||
@@ -361,13 +361,14 @@ usual operations on integers are supplied.</p>
|
|||||||
// if BOOST_ENDIAN_FORCE_PODNESS is defined && C++11 POD's are not
|
// if BOOST_ENDIAN_FORCE_PODNESS is defined && C++11 POD's are not
|
||||||
// available then these two constructors will not be present
|
// available then these two constructors will not be present
|
||||||
<a href="#endian">endian</a>() noexcept = default;
|
<a href="#endian">endian</a>() noexcept = default;
|
||||||
explicit <a href="#explicit-endian">endian</a>(T v) noexcept;
|
<a href="#explicit-endian">endian</a>(T v) noexcept;
|
||||||
|
|
||||||
endian& <a href="#operator-eq">operator=</a>(T v) noexcept;
|
endian& <a href="#operator-eq">operator=</a>(T v) noexcept;
|
||||||
<a href="#operator-T">operator T</a>() const noexcept;
|
<a href="#operator-T">operator T</a>() const noexcept;
|
||||||
const char* <a href="#data">data</a>() const noexcept;
|
const char* <a href="#data">data</a>() const noexcept;
|
||||||
|
|
||||||
// arithmetic operations; additional operators provided by value_type
|
// arithmetic operations
|
||||||
|
// note that additional operations are provided by the value_type
|
||||||
value_type operator+(const endian& x) noexcept;
|
value_type operator+(const endian& x) noexcept;
|
||||||
endian& operator+=(endian& x, value_type y) noexcept;
|
endian& operator+=(endian& x, value_type y) noexcept;
|
||||||
endian& operator-=(endian& x, value_type y) noexcept;
|
endian& operator-=(endian& x, value_type y) noexcept;
|
||||||
@@ -387,43 +388,44 @@ usual operations on integers are supplied.</p>
|
|||||||
endian operator--(endian& x, int) noexcept;
|
endian operator--(endian& x, int) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef endian<order::big, float, 32, align::yes> big_align_float32_t;
|
// aligned big endian floating point types
|
||||||
typedef endian<order::big, double, 64, align::yes> big_align_float64_t;
|
typedef endian<order::big, float, 32, align::yes> big_align_float32_t;
|
||||||
|
typedef endian<order::big, double, 64, align::yes> big_align_float64_t;
|
||||||
|
|
||||||
// aligned little endian floating point types
|
// aligned little endian floating point types
|
||||||
typedef endian<order::little, float, 32, align::yes> little_align_float32_t;
|
typedef endian<order::little, float, 32, align::yes> little_align_float32_t;
|
||||||
typedef endian<order::little, double, 64, align::yes> little_align_float64_t;
|
typedef endian<order::little, double, 64, align::yes> little_align_float64_t;
|
||||||
|
|
||||||
// unaligned big endian floating point types
|
// unaligned big endian floating point types
|
||||||
typedef endian<order::big, float, 32, align::no> big_float32un_t;
|
typedef endian<order::big, float, 32, align::no> big_float32un_t;
|
||||||
typedef endian<order::big, double, 64, align::no> big_float64un_t;
|
typedef endian<order::big, double, 64, align::no> big_float64un_t;
|
||||||
|
|
||||||
// unaligned little endian floating point types
|
// unaligned little endian floating point types
|
||||||
typedef endian<order::little, float, 32, align::no> little_float32un_t;
|
typedef endian<order::little, float, 32, align::no> little_float32un_t;
|
||||||
typedef endian<order::little, double, 64, align::no> little_float64un_t;
|
typedef endian<order::little, double, 64, align::no> little_float64un_t;
|
||||||
|
|
||||||
// aligned big endian signed integer types
|
// aligned big endian signed integer types
|
||||||
typedef endian<order::big, int16_t, 16, align::yes> big_align_int16_t;
|
typedef endian<order::big, int16_t, 16, align::yes> big_align_int16_t;
|
||||||
typedef endian<order::big, int32_t, 32, align::yes> big_align_int32_t;
|
typedef endian<order::big, int32_t, 32, align::yes> big_align_int32_t;
|
||||||
typedef endian<order::big, int64_t, 64, align::yes> big_align_int64_t;
|
typedef endian<order::big, int64_t, 64, align::yes> big_align_int64_t;
|
||||||
|
|
||||||
// aligned big endian unsigned integer types
|
// aligned big endian unsigned integer types
|
||||||
typedef endian<order::big, uint16_t, 16, align::yes> big_align_uint16_t;
|
typedef endian<order::big, uint16_t, 16, align::yes> big_align_uint16_t;
|
||||||
typedef endian<order::big, uint32_t, 32, align::yes> big_align_uint32_t;
|
typedef endian<order::big, uint32_t, 32, align::yes> big_align_uint32_t;
|
||||||
typedef endian<order::big, uint64_t, 64, align::yes> big_align_uint64_t;
|
typedef endian<order::big, uint64_t, 64, align::yes> big_align_uint64_t;
|
||||||
|
|
||||||
// aligned little endian signed integer types
|
// aligned little endian signed integer types
|
||||||
typedef endian<order::little, int16_t, 16, align::yes> little_align_int16_t;
|
typedef endian<order::little, int16_t, 16, align::yes> little_align_int16_t;
|
||||||
typedef endian<order::little, int32_t, 32, align::yes> little_align_int32_t;
|
typedef endian<order::little, int32_t, 32, align::yes> little_align_int32_t;
|
||||||
typedef endian<order::little, int64_t, 64, align::yes> little_align_int64_t;
|
typedef endian<order::little, int64_t, 64, align::yes> little_align_int64_t;
|
||||||
|
|
||||||
// aligned little endian unsigned integer types
|
// aligned little endian unsigned integer types
|
||||||
typedef endian<order::little, uint16_t, 16, align::yes> little_align_uint16_t;
|
typedef endian<order::little, uint16_t, 16, align::yes> little_align_uint16_t;
|
||||||
typedef endian<order::little, uint32_t, 32, align::yes> little_align_uint32_t;
|
typedef endian<order::little, uint32_t, 32, align::yes> little_align_uint32_t;
|
||||||
typedef endian<order::little, uint64_t, 64, align::yes> little_align_uint64_t;
|
typedef endian<order::little, uint64_t, 64, align::yes> little_align_uint64_t;
|
||||||
|
|
||||||
// aligned native endian typedefs are not provided because
|
// aligned native endian typedefs are not provided because
|
||||||
// <cstdint> types are superior for this use case
|
// <cstdint> types are superior for that use case
|
||||||
|
|
||||||
// unaligned big endian signed integer types
|
// unaligned big endian signed integer types
|
||||||
typedef endian<order::big, int_least8_t, 8> big_int8_t;
|
typedef endian<order::big, int_least8_t, 8> big_int8_t;
|
||||||
@@ -488,28 +490,30 @@ usual operations on integers are supplied.</p>
|
|||||||
} // namespace endian
|
} // namespace endian
|
||||||
} // namespace boost</pre>
|
} // namespace boost</pre>
|
||||||
<h3><a name="Members">Members</a></h3>
|
<h3><a name="Members">Members</a></h3>
|
||||||
<p><code><a name="endian">endian</a>() = default; // C++03: endian(){}</code></p>
|
<div dir="ltr">
|
||||||
|
<pre><code><a name="endian">endian</a>() = default; // C++03: endian(){}</code></pre>
|
||||||
|
</div>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><i>Effects:</i> Constructs an object of type <code>endian<E, T, n_bits, A></code>.</p>
|
<p><i>Effects:</i> Constructs an object of type <code>endian<E, T, n_bits, A></code>.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p><code><a name="explicit-endian">explicit endian</a>(T v);</code></p>
|
<pre><code><a name="explicit-endian">endian</a>(T v);</code></pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><i>Effects:</i> Constructs an object of type <code>endian<E, T, n_bits, A></code>.</p>
|
<p><i>Effects:</i> Constructs an object of type <code>endian<E, T, n_bits, A></code>.</p>
|
||||||
<p><i>Postcondition:</i> <code>x == v,</code> where <code>x</code> is the
|
<p><i>Postcondition:</i> <code>x == v,</code> where <code>x</code> is the
|
||||||
constructed object.</p>
|
constructed object.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p><code>endian& <a name="operator-eq">operator=</a>(T v);</code></p>
|
<pre><code>endian& <a name="operator-eq">operator=</a>(T v);</code></pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><i>Postcondition:</i> <code>x == v,</code> where <code>x</code> is the
|
<p><i>Postcondition:</i> <code>x == v,</code> where <code>x</code> is the
|
||||||
constructed object.</p>
|
constructed object.</p>
|
||||||
<p><i>Returns:</i> <code>*this</code>.</p>
|
<p><i>Returns:</i> <code>*this</code>.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p><code><a name="operator-T">operator T</a>() const;</code></p>
|
<pre><code><a name="operator-T">operator T</a>() const;</code></pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><i>Returns:</i> The current value stored in <code>*this</code>, converted to
|
<p><i>Returns:</i> The current value stored in <code>*this</code>, converted to
|
||||||
<code>value_type</code>.</p>
|
<code>value_type</code>.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
<p><code>const char* <a name="data">data</a>() const;</code></p>
|
<pre><code>const char* <a name="data">data</a>() const;</code></pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p><i>Returns:</i> A pointer to the first byte of the endian binary value stored
|
<p><i>Returns:</i> A pointer to the first byte of the endian binary value stored
|
||||||
in <code>*this</code>.</p>
|
in <code>*this</code>.</p>
|
||||||
@@ -617,7 +621,7 @@ differs from endian representation size. Vicente Botet and other reviewers
|
|||||||
suggested supporting floating point types.</p>
|
suggested supporting floating point types.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Last revised:
|
<p>Last revised:
|
||||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->31 August, 2013<!--webbot bot="Timestamp" endspan i-checksum="34505" --></p>
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->06 September, 2013<!--webbot bot="Timestamp" endspan i-checksum="39344" --></p>
|
||||||
<p>© Copyright Beman Dawes, 2006-2009, 2013</p>
|
<p>© Copyright Beman Dawes, 2006-2009, 2013</p>
|
||||||
<p>Distributed under the Boost Software License, Version 1.0. See
|
<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>
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
|
||||||
|
@@ -63,6 +63,12 @@
|
|||||||
# define BOOST_ENDIAN_NO_CTORS
|
# define BOOST_ENDIAN_NO_CTORS
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# ifndef BOOST_ENDIAN_EXPLICIT_CTORS
|
||||||
|
# define BOOST_ENDIAN_EXPLICIT_OPT
|
||||||
|
# else
|
||||||
|
# define BOOST_ENDIAN_EXPLICIT_OPT explicit
|
||||||
|
# endif
|
||||||
|
|
||||||
//---------------------------------- synopsis ----------------------------------------//
|
//---------------------------------- synopsis ----------------------------------------//
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
@@ -298,7 +304,7 @@ namespace endian
|
|||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(T val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
@@ -331,7 +337,7 @@ namespace endian
|
|||||||
typedef float value_type;
|
typedef float value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(value_type val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
|
||||||
{ detail::big_reverse_copy(val, m_value); }
|
{ detail::big_reverse_copy(val, m_value); }
|
||||||
# endif
|
# endif
|
||||||
endian & operator=(value_type val) BOOST_NOEXCEPT
|
endian & operator=(value_type val) BOOST_NOEXCEPT
|
||||||
@@ -356,7 +362,7 @@ namespace endian
|
|||||||
typedef double value_type;
|
typedef double value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(value_type val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
|
||||||
{ detail::big_reverse_copy(val, m_value); }
|
{ detail::big_reverse_copy(val, m_value); }
|
||||||
# endif
|
# endif
|
||||||
endian & operator=(value_type val) BOOST_NOEXCEPT
|
endian & operator=(value_type val) BOOST_NOEXCEPT
|
||||||
@@ -381,7 +387,7 @@ namespace endian
|
|||||||
typedef float value_type;
|
typedef float value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(value_type val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
|
||||||
{ detail::little_reverse_copy(val, m_value); }
|
{ detail::little_reverse_copy(val, m_value); }
|
||||||
# endif
|
# endif
|
||||||
endian & operator=(value_type val) BOOST_NOEXCEPT
|
endian & operator=(value_type val) BOOST_NOEXCEPT
|
||||||
@@ -406,7 +412,7 @@ namespace endian
|
|||||||
typedef double value_type;
|
typedef double value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(value_type val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(value_type val) BOOST_NOEXCEPT
|
||||||
{ detail::little_reverse_copy(val, m_value); }
|
{ detail::little_reverse_copy(val, m_value); }
|
||||||
# endif
|
# endif
|
||||||
endian & operator=(value_type val) BOOST_NOEXCEPT
|
endian & operator=(value_type val) BOOST_NOEXCEPT
|
||||||
@@ -432,7 +438,7 @@ namespace endian
|
|||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(T val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
@@ -467,9 +473,9 @@ namespace endian
|
|||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
explicit endian(T val) BOOST_NOEXCEPT { detail::store_big_endian<T, n_bits/8>(m_value, val); }
|
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT { detail::store_big_endian<T, n_bits/8>(m_value, val); }
|
||||||
# else
|
# else
|
||||||
explicit endian(T val) BOOST_NOEXCEPT { detail::store_little_endian<T, n_bits/8>(m_value, val); }
|
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT { detail::store_little_endian<T, n_bits/8>(m_value, val); }
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# ifdef BOOST_BIG_ENDIAN
|
# ifdef BOOST_BIG_ENDIAN
|
||||||
@@ -501,7 +507,7 @@ namespace endian
|
|||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(T val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
@@ -540,7 +546,7 @@ namespace endian
|
|||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian(T val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
|
@@ -14,10 +14,11 @@ project
|
|||||||
|
|
||||||
test-suite "endian"
|
test-suite "endian"
|
||||||
:
|
:
|
||||||
[ run endian_test.cpp
|
[ run endian_test.cpp # sources
|
||||||
: # command line
|
: # command line
|
||||||
: # input files
|
: # input files
|
||||||
: # requirements
|
: # requirements
|
||||||
|
: # target name
|
||||||
]
|
]
|
||||||
[ run endian_operations_test.cpp ]
|
[ run endian_operations_test.cpp ]
|
||||||
[ run endian_in_union_test.cpp ]
|
[ run endian_in_union_test.cpp ]
|
||||||
|
@@ -42,6 +42,8 @@
|
|||||||
# pragma warning( disable : 4389 ) // signed/unsigned mismatch
|
# pragma warning( disable : 4389 ) // signed/unsigned mismatch
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define BOOST_ENDIAN_LOG
|
||||||
|
|
||||||
#include <boost/endian/types.hpp>
|
#include <boost/endian/types.hpp>
|
||||||
#include <boost/type_traits/is_signed.hpp>
|
#include <boost/type_traits/is_signed.hpp>
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
@@ -341,6 +343,8 @@ void op_test()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void f_big_int32_t(be::big_int32_t) {}
|
||||||
|
|
||||||
// main ------------------------------------------------------------------------------//
|
// main ------------------------------------------------------------------------------//
|
||||||
|
|
||||||
int cpp_main(int, char * [])
|
int cpp_main(int, char * [])
|
||||||
@@ -364,6 +368,13 @@ int cpp_main(int, char * [])
|
|||||||
be::little_uint16_t little_u(10);
|
be::little_uint16_t little_u(10);
|
||||||
be::big_int64_t result;
|
be::big_int64_t result;
|
||||||
|
|
||||||
|
// this is the use case that is so irritating that it caused the endian
|
||||||
|
// constructors to be made non-explicit
|
||||||
|
std::clog << "\nf(1234) where f(big_int32_t)\n";
|
||||||
|
f_big_int32_t(1234);
|
||||||
|
|
||||||
|
std::clog << "\nresult = big\n";
|
||||||
|
result = big;
|
||||||
|
|
||||||
std::clog << "\nresult = +big\n";
|
std::clog << "\nresult = +big\n";
|
||||||
result = +big;
|
result = +big;
|
||||||
@@ -417,21 +428,26 @@ int cpp_main(int, char * [])
|
|||||||
result = 5 * 10;
|
result = 5 * 10;
|
||||||
std::clog << "\n";
|
std::clog << "\n";
|
||||||
|
|
||||||
be::endian_log = false;
|
// test from Roland Schwarz that detected ambiguities; these ambiguities
|
||||||
|
// were eliminated by BOOST_MINIMAL_INTEGER_COVER_OPERATORS
|
||||||
// test from Roland Schwarz that detected ambiguities
|
|
||||||
unsigned u;
|
unsigned u;
|
||||||
be::little_uint32_t u1;
|
be::little_uint32_t u1;
|
||||||
be::little_uint32_t u2;
|
be::little_uint32_t u2;
|
||||||
|
|
||||||
u = 1;
|
u = 9;
|
||||||
u1 = 1;
|
u1 = 1;
|
||||||
|
std::clog << "\nu2 = u1 + u\n";
|
||||||
u2 = u1 + u;
|
u2 = u1 + u;
|
||||||
|
std::clog << "\n";
|
||||||
|
|
||||||
// one more wrinkle
|
// one more wrinkle
|
||||||
be::little_uint16_t u3(3);
|
be::little_uint16_t u3(3);
|
||||||
u3 = 3;
|
u3 = 3;
|
||||||
|
std::clog << "\nu2 = u1 + u3\n";
|
||||||
u2 = u1 + u3;
|
u2 = u1 + u3;
|
||||||
|
std::clog << "\n";
|
||||||
|
|
||||||
|
be::endian_log = false;
|
||||||
|
|
||||||
// perform the indicated test on ~60*60 operand types
|
// perform the indicated test on ~60*60 operand types
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user