[PATCH] Add new helper traits for signed/unsigned integer types

Jonathan Wakely jwakely@redhat.com
Wed Jun 26 14:38:00 GMT 2019


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.

Tested x86_64-linux, committed to trunk.


-------------- next part --------------
commit 95d162498f763e8780f188459d878476a6c52aeb
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Jun 26 14:38:23 2019 +0000

    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.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272695 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index 0a8ab0de2ff..e1083acf30f 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -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
-		is_same<_Ch, wchar_t>,
-		is_same<_Ch, char16_t>,
-		is_same<_Ch, char32_t>>;
+#if _GLIBCXX_USE_WCHAR_T
+	    wchar_t,
+#endif
+	    char16_t, char32_t>;
 
     template<typename _Iter,
 	     typename _Iter_traits = std::iterator_traits<_Iter>>
diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit
index e0c53e53756..dd33dcfdcf6 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
diff --git a/libstdc++-v3/include/std/charconv b/libstdc++-v3/include/std/charconv
index a777f60501d..6a3399764ba 100644
--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -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
 
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 7d4deb156a1..b07291706ac 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -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>
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc
index 6ffb5f70edb..84f3ac156c3 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ceil2.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/floor2.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/floor2.cc
index a18f14ff988..aff9138650e 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/floor2.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/floor2.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ispow2.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ispow2.cc
index 8ab8b717504..869197627d4 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ispow2.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/ispow2.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/log2p1.cc b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/log2p1.cc
index 0aa8a6c40f6..aeb5486b909 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/log2p1.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bit.pow.two/log2p1.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc
index 6fc634d55b5..50b681c0090 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_one.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc
index 64049a32e0e..8c8a13fed34 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countl_zero.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc
index 3218ef7b52d..16c98579316 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_one.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc
index 2f8505cb1fd..0e1970b2af6 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/countr_zero.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc
index aea16214bea..07b8c6ac4e2 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.count/popcount.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotl.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotl.cc
index 94be65c3d13..2d97ae8c465 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotl.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotl.cc
@@ -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() );
diff --git a/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotr.cc b/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotr.cc
index 3f1539aadbb..c41c24d816a 100644
--- a/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotr.cc
+++ b/libstdc++-v3/testsuite/26_numerics/bit/bitops.rot/rotr.cc
@@ -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() );


More information about the Libstdc++ mailing list