aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std/bit
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-06-26 15:38:23 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-06-26 15:38:23 +0100
commit47f7905440afb294e8b6486196bc961527425739 (patch)
tree72df26fa6ab612435a57d0f06017fbf18b87847f /libstdc++-v3/include/std/bit
parent7cbb1b721e650036a49dc0013397fee34af12800 (diff)
downloadgcc-47f7905440afb294e8b6486196bc961527425739.zip
gcc-47f7905440afb294e8b6486196bc961527425739.tar.gz
gcc-47f7905440afb294e8b6486196bc961527425739.tar.bz2
Add new helper traits for signed/unsigned integer types
Reuse the __is_one_of alias in additional places, and define traits to check for signed/unsigned integer types so we don't have to duplicate those checks elsewhere. The additional overloads for std::byte in <bit> were reviewed by LEWG and considered undesirable, so this patch removes them. * include/bits/fs_path.h (path::__is_encoded_char): Use __is_one_of. * include/std/bit (_If_is_unsigned_integer_type): Remove. (_If_is_unsigned_integer): Use __is_unsigned_integer. (rotl(byte, unsigned), rotr(byte, unsigned), countl_zero(byte)) (countl_one(byte), countr_zero(byte), countr_one(byte)) (popcount(byte), ispow2(byte), ceil2(byte), floor2(byte)) (log2p1(byte)): Remove. * include/std/charconv (__detail::__is_one_of): Move to <type_traits>. (__detail::__is_int_to_chars_type): Remove. (__detail::__integer_to_chars_result_type): Use __is_signed_integer and __is_unsigned_integer. * include/std/type_traits (__is_one_of): Move here from <charconv>. (__is_signed_integer, __is_unsigned_integer): New helpers. * testsuite/26_numerics/bit/bit.pow.two/ceil2.cc: Remove test for std::byte overload. * testsuite/26_numerics/bit/bit.pow.two/floor2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/ispow2.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/log2p1.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countl_one.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countl_zero.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countr_one.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/countr_zero.cc: Likewise. * testsuite/26_numerics/bit/bitops.count/popcount.cc: Likewise. * testsuite/26_numerics/bit/bitops.rot/rotl.cc: Likewise. * testsuite/26_numerics/bit/bitops.rot/rotr.cc: Likewise. From-SVN: r272695
Diffstat (limited to 'libstdc++-v3/include/std/bit')
-rw-r--r--libstdc++-v3/include/std/bit60
1 files changed, 1 insertions, 59 deletions
diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index e0c53e5..dd33dcf 100644
--- a/libstdc++-v3/include/std/bit
+++ b/libstdc++-v3/include/std/bit
@@ -222,19 +222,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus > 201703L
- template<typename _Tp, typename _Up, bool = is_integral_v<_Tp>>
- struct _If_is_unsigned_integer_type { };
-
- template<typename _Up>
- struct _If_is_unsigned_integer_type<bool, _Up, true> { };
-
- template<typename _Tp, typename _Up>
- struct _If_is_unsigned_integer_type<_Tp, _Up, true>
- : enable_if<is_same_v<_Tp, make_unsigned_t<_Tp>>, _Up> { };
-
template<typename _Tp, typename _Up = _Tp>
using _If_is_unsigned_integer
- = typename _If_is_unsigned_integer_type<remove_cv_t<_Tp>, _Up>::type;
+ = enable_if_t<__is_unsigned_integer<_Tp>::value, _Up>;
#if ! __STRICT_ANSI__
// [bitops.rot], rotating
@@ -299,54 +289,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
log2p1(_Tp __x) noexcept
{ return std::__log2p1(__x); }
-#if ! __STRICT_ANSI__
- enum class byte : unsigned char;
-
- constexpr byte
- rotl(byte __x, unsigned int __s) noexcept
- { return (byte)std::__rotl((unsigned char)__x, __s); }
-
- constexpr byte
- rotr(byte __x, unsigned int __s) noexcept
- { return (byte)std::__rotr((unsigned char)__x, __s); }
-
- constexpr int
- countl_zero(byte __x) noexcept
- { return std::__countl_zero((unsigned char)__x); }
-
- constexpr int
- countl_one(byte __x) noexcept
- { return std::__countl_one((unsigned char)__x); }
-
- constexpr int
- countr_zero(byte __x) noexcept
- { return std::__countr_zero((unsigned char)__x); }
-
- constexpr int
- countr_one(byte __x) noexcept
- { return std::__countr_one((unsigned char)__x); }
-
- constexpr int
- popcount(byte __x) noexcept
- { return std::__popcount((unsigned char)__x); }
-
- constexpr bool
- ispow2(byte __x) noexcept
- { return std::__ispow2((unsigned char)__x); }
-
- constexpr byte
- ceil2(byte __x) noexcept
- { return (byte)std::__ceil2((unsigned char)__x); }
-
- constexpr byte
- floor2(byte __x) noexcept
- { return (byte)std::__floor2((unsigned char)__x); }
-
- constexpr byte
- log2p1(byte __x) noexcept
- { return (byte)std::__log2p1((unsigned char)__x); }
-#endif
-
#endif // C++2a
_GLIBCXX_END_NAMESPACE_VERSION