forked from boostorg/endian
Eliminate gcc -Wconversion warnings.
This commit is contained in:
@@ -236,19 +236,19 @@ namespace endian
|
||||
typedef unrolled_byte_loops<T, n_bytes - 1, sign> next;
|
||||
|
||||
static T load_big(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return *(bytes - 1) | (next::load_big(bytes - 1) << 8); }
|
||||
{ return static_cast<T>(*(bytes - 1) | (next::load_big(bytes - 1) << 8)); }
|
||||
static T load_little(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return *bytes | (next::load_little(bytes + 1) << 8); }
|
||||
{ return static_cast<T>(*bytes | (next::load_little(bytes + 1) << 8)); }
|
||||
|
||||
static void store_big(char* bytes, T value) BOOST_NOEXCEPT
|
||||
{
|
||||
*(bytes - 1) = static_cast<char>(value);
|
||||
next::store_big(bytes - 1, value >> 8);
|
||||
next::store_big(bytes - 1, static_cast<T>(value >> 8));
|
||||
}
|
||||
static void store_little(char* bytes, T value) BOOST_NOEXCEPT
|
||||
{
|
||||
*bytes = static_cast<char>(value);
|
||||
next::store_little(bytes + 1, value >> 8);
|
||||
next::store_little(bytes + 1, static_cast<T>(value >> 8));
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -62,20 +62,32 @@ namespace boost
|
||||
# endif
|
||||
|
||||
// The basic arithmetic operations.
|
||||
friend D& operator+=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x + y; }
|
||||
friend D& operator-=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x - y; }
|
||||
friend D& operator*=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x * y; }
|
||||
friend D& operator/=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x / y; }
|
||||
friend D& operator%=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x % y; }
|
||||
friend D& operator&=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x & y; }
|
||||
friend D& operator|=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x | y; }
|
||||
friend D& operator^=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x ^ y; }
|
||||
friend D& operator<<=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x << y; }
|
||||
friend D& operator>>=(D& x, ArithmeticT y) BOOST_NOEXCEPT { return x = +x >> y; }
|
||||
friend D& operator+=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x + y); }
|
||||
friend D& operator-=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x - y); }
|
||||
friend D& operator*=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x * y); }
|
||||
friend D& operator/=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x / y); }
|
||||
friend D& operator%=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x % y); }
|
||||
friend D& operator&=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x & y); }
|
||||
friend D& operator|=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x | y); }
|
||||
friend D& operator^=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x ^ y); }
|
||||
friend D& operator<<=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x << y); }
|
||||
friend D& operator>>=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x >> y); }
|
||||
|
||||
// A few binary arithmetic operations not covered by operators base class.
|
||||
friend ArithmeticT operator<<(const D& x, ArithmeticT y) BOOST_NOEXCEPT { return +x << y; }
|
||||
friend ArithmeticT operator>>(const D& x, ArithmeticT y) BOOST_NOEXCEPT { return +x >> y; }
|
||||
friend ArithmeticT operator<<(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return static_cast<ArithmeticT>(+x << y); }
|
||||
friend ArithmeticT operator>>(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return static_cast<ArithmeticT>(+x >> y); }
|
||||
|
||||
// Auto-increment and auto-decrement can be defined in terms of the
|
||||
// arithmetic operations.
|
||||
|
@@ -74,7 +74,7 @@ namespace
|
||||
++v; // verify integer_cover_operators being applied to this type -
|
||||
// will fail to compile if no endian<> specialization is present
|
||||
|
||||
Endian x(v+v);
|
||||
Endian x(static_cast<typename Endian::value_type>(v+v));
|
||||
if ( x == x ) // silence warning
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user