diff options
| author | Marshall Clow <mclow.lists@gmail.com> | 2017-03-24 05:45:39 +0000 |
|---|---|---|
| committer | Marshall Clow <mclow.lists@gmail.com> | 2017-03-24 05:45:39 +0000 |
| commit | c97d8aa86650ed795bf75a7dd735ecfaef3b8f55 (patch) | |
| tree | d6ea6f94a2783b4cbb282d8ea1efb21268544733 /libcxx/include/cstddef | |
| parent | 059b98e044873f7c7e56f2caa654281279d8d060 (diff) | |
| download | bcm5719-llvm-c97d8aa86650ed795bf75a7dd735ecfaef3b8f55.tar.gz bcm5719-llvm-c97d8aa86650ed795bf75a7dd735ecfaef3b8f55.zip | |
Implement P0298R3: 'std::byte'. Reviewed as https://reviews.llvm.org/D31022
llvm-svn: 298689
Diffstat (limited to 'libcxx/include/cstddef')
| -rw-r--r-- | libcxx/include/cstddef | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef index 103898b7d8b..62584494d97 100644 --- a/libcxx/include/cstddef +++ b/libcxx/include/cstddef @@ -28,6 +28,7 @@ Types: size_t max_align_t nullptr_t + byte // C++17 } // std @@ -58,4 +59,32 @@ typedef long double max_align_t; _LIBCPP_END_NAMESPACE_STD +#if _LIBCPP_STD_VER > 14 +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)); } + +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)); } + +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)); } + +constexpr byte operator~ (byte __b) noexcept +{ return byte(~static_cast<unsigned char>(__b)); } + +} + +#include <type_traits> // rest of byte +#endif + #endif // _LIBCPP_CSTDDEF |

