From: redi Date: Wed, 26 Jun 2019 14:38:23 +0000 (+0000) Subject: Add new helper traits for signed/unsigned integer types X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95d162498f763e8780f188459d878476a6c52aeb;p=thirdparty%2Fgcc.git 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 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 . (__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 . (__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/ChangeLog b/libstdc++-v3/ChangeLog index 7222810984df..88e8ed65e106 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,31 @@ +2019-06-26 Jonathan Wakely + + * 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 . + (__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 . + (__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 * include/std/numeric (midpoint(T, T)): Avoid std::abs in constexpr diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 0a8ab0de2ffb..e1083acf30f5 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> - using __is_encoded_char - = __or_, + template + using __is_encoded_char = __is_one_of, + 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> diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit index e0c53e537563..dd33dcfdcf6f 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> - struct _If_is_unsigned_integer_type { }; - - template - struct _If_is_unsigned_integer_type { }; - - template - struct _If_is_unsigned_integer_type<_Tp, _Up, true> - : enable_if>, _Up> { }; - template using _If_is_unsigned_integer - = typename _If_is_unsigned_integer_type, _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 a777f60501de..6a3399764ba7 100644 --- a/libstdc++-v3/include/std/charconv +++ b/libstdc++-v3/include/std/charconv @@ -61,23 +61,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION namespace __detail { - template - using __is_one_of = __or_...>; - - template - using __is_int_to_chars_type = __and_, - __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 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>>, + 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 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>>, + from_chars_result>; } // namespace __detail diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 7d4deb156a16..b07291706ac9 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::type>::type { }; + template + struct is_same; + + template + using __is_one_of = __or_...>; + + // Check if a type is one of the signed integer types. + template + using __is_signed_integer = __is_one_of::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 + using __is_unsigned_integer = __is_one_of::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 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 6ffb5f70edb9..84f3ac156c3f 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 -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 +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 a18f14ff9889..aff9138650eb 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 -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 +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 8ab8b7175040..869197627d4e 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 -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 +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 0aa8a6c40f61..aeb5486b9092 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 -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 +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 6fc634d55b58..50b681c00900 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 -constexpr int bits = std::numeric_limits::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 +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 64049a32e0e4..8c8a13fed34e 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 -constexpr int bits = std::numeric_limits::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 +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 3218ef7b52d9..16c98579316e 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 -constexpr int bits = std::numeric_limits::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 +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 2f8505cb1fd1..0e1970b2af69 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 -constexpr int bits = std::numeric_limits::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 +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 aea16214beab..07b8c6ac4e25 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 -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 +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 94be65c3d138..2d97ae8c4657 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 -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 +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 3f1539aadbb3..c41c24d816a5 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 -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 +static_assert( test( (std::byte)0 ).did_not_match() );