+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
/// 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>>
#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
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
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
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
: 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>
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );
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() );