forked from OSchip/llvm-project
Implement LWG2950: std::byte operations are misspecified
llvm-svn: 318125
This commit is contained in:
parent
1594feea94
commit
12de6e9c11
|
@ -64,23 +64,46 @@ namespace std // purposefully not versioned
|
|||
{
|
||||
enum class byte : unsigned char {};
|
||||
|
||||
constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); }
|
||||
constexpr byte operator| (byte __lhs, byte __rhs) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) | static_cast<unsigned char>(__rhs)); }
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator|=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = __lhs | __rhs; }
|
||||
|
||||
constexpr byte operator& (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator&=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); }
|
||||
constexpr byte operator& (byte __lhs, byte __rhs) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) & static_cast<unsigned char>(__rhs)); }
|
||||
{ return __lhs = __lhs & __rhs; }
|
||||
|
||||
constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)
|
||||
));
|
||||
}
|
||||
|
||||
constexpr byte& operator^=(byte& __lhs, byte __rhs) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); }
|
||||
constexpr byte operator^ (byte __lhs, byte __rhs) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) ^ static_cast<unsigned char>(__rhs)); }
|
||||
{ return __lhs = __lhs ^ __rhs; }
|
||||
|
||||
constexpr byte operator~ (byte __b) noexcept
|
||||
{ return byte(~static_cast<unsigned char>(__b)); }
|
||||
{
|
||||
return static_cast<byte>(
|
||||
static_cast<unsigned char>(
|
||||
~static_cast<unsigned int>(__b)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4761,26 +4761,26 @@ namespace std // purposefully not versioned
|
|||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
|
||||
operator<<=(byte& __lhs, _Integer __shift) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) << __shift); }
|
||||
{ return __lhs = __lhs << __shift; }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
|
||||
operator<< (byte __lhs, _Integer __shift) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) << __shift); }
|
||||
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift)); }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type &
|
||||
operator>>=(byte& __lhs, _Integer __shift) noexcept
|
||||
{ return __lhs = byte(static_cast<unsigned char>(__lhs) >> __shift); }
|
||||
{ return __lhs = __lhs >> __shift; }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, byte>::type
|
||||
operator>> (byte __lhs, _Integer __shift) noexcept
|
||||
{ return byte(static_cast<unsigned char>(__lhs) >> __shift); }
|
||||
{ return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift)); }
|
||||
|
||||
template <class _Integer>
|
||||
constexpr typename enable_if<is_integral_v<_Integer>, _Integer>::type
|
||||
to_integer(byte __b) noexcept { return _Integer(__b); }
|
||||
to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); }
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
<tr><td><a href="https://wg21.link/LWG2944">2944</a></td><td>LWG 2905 accidentally removed requirement that construction of the deleter doesn't throw an exception</td><td>Albuquerque</td><td><i>Nothing to do</i></td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2945">2945</a></td><td>Order of template parameters in optional comparisons</td><td>Albuquerque</td><td>Complete</td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2948">2948</a></td><td>unique_ptr does not define operator<< for stream output</td><td>Albuquerque</td><td></td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2950">2950</a></td><td>std::byte operations are misspecified</td><td>Albuquerque</td><td></td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2950">2950</a></td><td>std::byte operations are misspecified</td><td>Albuquerque</td><td>Complete</td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2952">2952</a></td><td>iterator_traits should work for pointers to cv T</td><td>Albuquerque</td><td>Complete</td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2953">2953</a></td><td>LWG 2853 should apply to deque::erase too</td><td>Albuquerque</td><td></td></tr>
|
||||
<tr><td><a href="https://wg21.link/LWG2958">2958</a></td><td>Moves improperly defined as deleted</td><td>Albuquerque</td><td></td></tr>
|
||||
|
|
Loading…
Reference in New Issue