]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add new helper traits for signed/unsigned integer types
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Jun 2019 14:38:23 +0000 (14:38 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Jun 2019 14:38:23 +0000 (14:38 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272695 138bc75d-0d04-0410-961f-82ee72b054a4

16 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fs_path.h
libstdc++-v3/include/std/bit
libstdc++-v3/include/std/charconv
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/floor2.cc
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ispow2.cc
libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/log2p1.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotl.cc
libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotr.cc

index 7222810984dfc71ede58dfe35bfb41d9f49bff45..88e8ed65e1066e4ad26cc188026dcf98df88f542 100644 (file)
@@ -1,3 +1,31 @@
+2019-06-26  Jonathan Wakely  <jwakely@redhat.com>
+
+       * 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.
+
 2019-06-25  Jonathan Wakely  <jwakely@redhat.com>
 
        * include/std/numeric (midpoint(T, T)): Avoid std::abs in constexpr
index 0a8ab0de2ffb0b18d63a445105648ef2fa053d08..e1083acf30f54e558c4adaac2a09420590ae800d 100644 (file)
@@ -66,15 +66,16 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   /// A filesystem path.
   class path
   {
-    template<typename _CharT, typename _Ch = remove_const_t<_CharT>>
-      using __is_encoded_char
-       = __or_<is_same<_Ch, char>,
+    template<typename _CharT>
+      using __is_encoded_char = __is_one_of<remove_const_t<_CharT>,
+           char,
 #ifdef _GLIBCXX_USE_CHAR8_T
-               is_same<_Ch, char8_t>,
+           char8_t,
+#endif
+#if _GLIBCXX_USE_WCHAR_T
+           wchar_t,
 #endif
-               is_same<_Ch, wchar_t>,
-               is_same<_Ch, char16_t>,
-               is_same<_Ch, char32_t>>;
+           char16_t, char32_t>;
 
     template<typename _Iter,
             typename _Iter_traits = std::iterator_traits<_Iter>>
index e0c53e53756384d0333ef819c8b1e60e0f36329e..dd33dcfdcf6f97f2db04e42d85eed5ab6f6688ed 100644 (file)
@@ -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
index a777f60501debfbabde5f6b4e7ca72d2321d18dd..6a3399764ba753fa13bc93346a5a93eb95fcb2d9 100644 (file)
@@ -61,23 +61,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 namespace __detail
 {
-  template<typename _Tp, typename... _Types>
-    using __is_one_of = __or_<is_same<_Tp, _Types>...>;
-
-  template<typename _Tp>
-    using __is_int_to_chars_type = __and_<is_integral<_Tp>,
-         __not_<__is_one_of<_Tp, bool, char16_t, char32_t
-#if _GLIBCXX_USE_WCHAR_T
-         , wchar_t
-#endif
-#if _GLIBCXX_USE_CHAR8_T
-         , char8_t
-#endif
-           >>>;
-
   template<typename _Tp>
     using __integer_to_chars_result_type
-      = enable_if_t<__is_int_to_chars_type<_Tp>::value, to_chars_result>;
+      = enable_if_t<__or_v<__is_signed_integer<_Tp>,
+                          __is_unsigned_integer<_Tp>,
+                          is_same<char, remove_cv_t<_Tp>>>,
+                   to_chars_result>;
 
   // Pick an unsigned type of suitable size. This is used to reduce the
   // number of specializations of __to_chars_len, __to_chars etc. that
@@ -555,7 +544,10 @@ namespace __detail
 
   template<typename _Tp>
     using __integer_from_chars_result_type
-      = enable_if_t<__is_int_to_chars_type<_Tp>::value, from_chars_result>;
+      = enable_if_t<__or_v<__is_signed_integer<_Tp>,
+                          __is_unsigned_integer<_Tp>,
+                          is_same<char, remove_cv_t<_Tp>>>,
+                   from_chars_result>;
 
 } // namespace __detail
 
index 7d4deb156a1616acfa51388d9cd62a967abe4d2f..b07291706ac9bea3b98af51245a29f65e273dcfd 100644 (file)
@@ -659,6 +659,51 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     : public __is_member_pointer_helper<typename remove_cv<_Tp>::type>::type
     { };
 
+  template<typename, typename>
+    struct is_same;
+
+  template<typename _Tp, typename... _Types>
+    using __is_one_of = __or_<is_same<_Tp, _Types>...>;
+
+  // Check if a type is one of the signed integer types.
+  template<typename _Tp>
+    using __is_signed_integer = __is_one_of<typename remove_cv<_Tp>::type,
+         signed char, signed short, signed int, signed long,
+         signed long long
+#if defined(__GLIBCXX_TYPE_INT_N_0)
+         , signed __GLIBCXX_TYPE_INT_N_0
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_1)
+         , signed __GLIBCXX_TYPE_INT_N_1
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_2)
+         , signed __GLIBCXX_TYPE_INT_N_2
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_3)
+         , signed __GLIBCXX_TYPE_INT_N_3
+#endif
+         >;
+
+  // Check if a type is one of the unsigned integer types.
+  template<typename _Tp>
+    using __is_unsigned_integer = __is_one_of<typename remove_cv<_Tp>::type,
+         unsigned char, unsigned short, unsigned int, unsigned long,
+         unsigned long long
+#if defined(__GLIBCXX_TYPE_INT_N_0)
+         , unsigned __GLIBCXX_TYPE_INT_N_0
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_1)
+         , unsigned __GLIBCXX_TYPE_INT_N_1
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_2)
+         , unsigned __GLIBCXX_TYPE_INT_N_2
+#endif
+#if defined(__GLIBCXX_TYPE_INT_N_3)
+         , unsigned __GLIBCXX_TYPE_INT_N_3
+#endif
+         >;
+
+
   // Utility to detect referenceable types ([defns.referenceable]).
 
   template<typename _Tp>
index 6ffb5f70edb9bea666447e3ff0997eac18411bc4..84f3ac156c3f02be80c4ebf8690cc18dfa8b3fab 100644 (file)
@@ -86,18 +86,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::ceil2(std::byte{0}) == std::byte{1} );
-static_assert( std::ceil2(std::byte{1}) == std::byte{1} );
-static_assert( std::ceil2(std::byte{2}) == std::byte{2} );
-static_assert( std::ceil2(std::byte{3}) == std::byte{4} );
-static_assert( std::ceil2(std::byte{100}) == std::byte{128} );
-static_assert( std::ceil2(std::byte{128}) == std::byte{128} );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -114,3 +102,10 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+#if defined(__GLIBCXX_TYPE_INT_N_3)
+static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_3)0 ) );
+static_assert( test( (__GLIBCXX_TYPE_INT_N_3)0 ).did_not_match() );
+#endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index a18f14ff98897a15803975bc178d6dcfb97900a9..aff9138650eb92bb577896f0f74a85747ed98ed5 100644 (file)
@@ -78,19 +78,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::floor2(std::byte{0}) == std::byte{0} );
-static_assert( std::floor2(std::byte{1}) == std::byte{1} );
-static_assert( std::floor2(std::byte{2}) == std::byte{2} );
-static_assert( std::floor2(std::byte{3}) == std::byte{2} );
-static_assert( std::floor2(std::byte{100}) == std::byte{64} );
-static_assert( std::floor2(std::byte{128}) == std::byte{128} );
-static_assert( std::floor2(std::byte{255}) == std::byte{128} );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -107,3 +94,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 8ab8b7175040e131751a5237edf0a4039240227d..869197627d4ebda0ddf15943612f9354a3b2fd32 100644 (file)
@@ -126,19 +126,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::ispow2(std::byte{0}) == false );
-static_assert( std::ispow2(std::byte{1}) == true );
-static_assert( std::ispow2(std::byte{2}) == true );
-static_assert( std::ispow2(std::byte{3}) == false );
-static_assert( std::ispow2(std::byte{100}) == false );
-static_assert( std::ispow2(std::byte{128}) == true );
-static_assert( std::ispow2(std::byte{255}) == false );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -155,3 +142,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 0aa8a6c40f6183143fa1f913be638b52c5b3894f..aeb5486b90921833198f831b0d0b2ee1310167df 100644 (file)
@@ -78,19 +78,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::log2p1(std::byte{0}) == std::byte{0} );
-static_assert( std::log2p1(std::byte{1}) == std::byte{1} );
-static_assert( std::log2p1(std::byte{2}) == std::byte{2} );
-static_assert( std::log2p1(std::byte{3}) == std::byte{2} );
-static_assert( std::log2p1(std::byte{100}) == std::byte{7} );
-static_assert( std::log2p1(std::byte{128}) == std::byte{8} );
-static_assert( std::log2p1(std::byte{255}) == std::byte{8} );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -107,3 +94,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 6fc634d55b588df8414c900d36de116a98a55cff..50b681c00900f5e7a9d0e62b94b3b0864219456b 100644 (file)
@@ -73,16 +73,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-constexpr int bits = std::numeric_limits<unsigned char>::digits;
-static_assert( std::countl_one(std::byte{0}) == 0 );
-static_assert( std::countl_one(~std::byte{0}) == bits );
-static_assert( std::countl_one(~std::byte{0} ^ std::byte{7}) == bits - 3 );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -99,3 +89,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 64049a32e0e4f7deac8a9a582497529059e19059..8c8a13fed34e02bcbc45828e6f2345175def674f 100644 (file)
@@ -70,20 +70,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-constexpr int bits = std::numeric_limits<unsigned char>::digits;
-static_assert( std::countl_zero(std::byte{0}) == bits );
-static_assert( std::countl_zero(std::byte{0x01}) == bits - 1 );
-static_assert( std::countl_zero(std::byte{0x02}) == bits - 2 );
-static_assert( std::countl_zero(std::byte{0x03}) == bits - 2 );
-static_assert( std::countl_zero(std::byte{0x30}) == 2 );
-static_assert( std::countl_zero(std::byte{0x40}) == 1 );
-static_assert( std::countl_zero(std::byte{0x41}) == 1 );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -100,3 +86,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 3218ef7b52d95806c2152e2ba877b7fd0c784650..16c98579316ec4248d0b5434eac68b826e8a1239 100644 (file)
@@ -72,20 +72,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-constexpr int bits = std::numeric_limits<unsigned char>::digits;
-static_assert( std::countr_one(std::byte{0}) == 0 );
-static_assert( std::countr_one(std::byte{0x01}) == 1 );
-static_assert( std::countr_one(std::byte{0x02}) == 0 );
-static_assert( std::countr_one(std::byte{0x03}) == 2 );
-static_assert( std::countr_one(std::byte{0x30}) == 0 );
-static_assert( std::countr_one(std::byte{0x0f}) == 4 );
-static_assert( std::countr_one(std::byte{0xff}) == 8 );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -102,3 +88,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 2f8505cb1fd1caa42a84bdd506c965bba35710bd..0e1970b2af6903f6f92eb6ae90899bb8e598373b 100644 (file)
@@ -71,20 +71,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-constexpr int bits = std::numeric_limits<unsigned char>::digits;
-static_assert( std::countr_zero(std::byte{0}) == bits );
-static_assert( std::countr_zero(std::byte{0x01}) == 0 );
-static_assert( std::countr_zero(std::byte{0x02}) == 1 );
-static_assert( std::countr_zero(std::byte{0x03}) == 0 );
-static_assert( std::countr_zero(std::byte{0x30}) == 4 );
-static_assert( std::countr_zero(std::byte{0x40}) == 6 );
-static_assert( std::countr_zero(std::byte{0x41}) == 0 );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -101,3 +87,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index aea16214beab6bc3adf9ea80b7dae0c41f044860..07b8c6ac4e254956410c856577542c51150a90d9 100644 (file)
@@ -74,20 +74,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::popcount(std::byte{0x00}) == 0 );
-static_assert( std::popcount(std::byte{0x01}) == 1 );
-static_assert( std::popcount(std::byte{0x02}) == 1 );
-static_assert( std::popcount(std::byte{0x03}) == 2 );
-static_assert( std::popcount(std::byte{0x30}) == 2 );
-static_assert( std::popcount(std::byte{0x40}) == 1 );
-static_assert( std::popcount(std::byte{0x41}) == 2 );
-static_assert( std::popcount(std::byte{0xff}) == 8 );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -104,3 +90,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 94be65c3d138389db2cf7955c12667687e5b1419..2d97ae8c46574a85ad3af8e0527fd74ab4d19570 100644 (file)
@@ -86,19 +86,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::rotl(std::byte{0}, 4) == std::byte{0} );
-static_assert( std::rotl(std::byte{0x01}, 4) == std::byte{0x10} );
-static_assert( std::rotl(std::byte{0x02}, 3) == std::byte{0x10} );
-static_assert( std::rotl(std::byte{0x03}, 2) == std::byte{0x0c} );
-static_assert( std::rotl(std::byte{0x30}, 2) == std::byte{0xc0} );
-static_assert( std::rotl(std::byte{0x40}, 1) == std::byte{0x80} );
-static_assert( std::rotl(std::byte{0x41}, 9) == std::byte{0x82} );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -115,3 +102,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );
index 3f1539aadbb3dc089f2dd44c17e5e12ae8b0f058..c41c24d816a54d577a2f98a359c3990cf21e977e 100644 (file)
@@ -88,19 +88,6 @@ static_assert( test( X{} ).did_not_match() );
 enum E : unsigned { e };
 static_assert( test( e ).did_not_match() );
 
-#ifndef __STRICT_ANSI__
-#include <cstddef>
-static_assert( std::rotr(std::byte{0}, 4) == std::byte{0} );
-static_assert( std::rotr(std::byte{0x01}, 4) == std::byte{0x10} );
-static_assert( std::rotr(std::byte{0x02}, 3) == std::byte{0x40} );
-static_assert( std::rotr(std::byte{0x03}, 2) == std::byte{0xc0} );
-static_assert( std::rotr(std::byte{0x30}, 2) == std::byte{0x0c} );
-static_assert( std::rotr(std::byte{0x40}, 1) == std::byte{0x20} );
-static_assert( std::rotr(std::byte{0x41}, 9) == std::byte{0xa0} );
-#else
-static_assert( test( (std::byte)0 ).did_not_match() );
-#endif
-
 #if !defined(__STRICT_ANSI__) && defined _GLIBCXX_USE_INT128
 static_assert( test( (unsigned __int128)0 ) );
 static_assert( test( (__int128)0 ).did_not_match() );
@@ -117,3 +104,6 @@ static_assert( test( (__GLIBCXX_TYPE_INT_N_1)0 ).did_not_match() );
 static_assert( test( (unsigned __GLIBCXX_TYPE_INT_N_2)0 ) );
 static_assert( test( (__GLIBCXX_TYPE_INT_N_2)0 ).did_not_match() );
 #endif
+
+#include <cstddef>
+static_assert( test( (std::byte)0 ).did_not_match() );