diff options
author | Martin Liska <mliska@suse.cz> | 2022-09-26 21:05:44 +0200 |
---|---|---|
committer | Martin Liska <mliska@suse.cz> | 2022-09-26 21:05:44 +0200 |
commit | 3c527a35fa428b727807c81f1225a5e0025446c1 (patch) | |
tree | 787e21d7bf8a1d85ac7b9ccee784909e85ebf61b /libstdc++-v3 | |
parent | c9c59aa19c0b7159636763294b7b0c87c696d675 (diff) | |
parent | 7701ea4a70a5a5c0fd977da90a30ffc4f3f87617 (diff) | |
download | gcc-3c527a35fa428b727807c81f1225a5e0025446c1.zip gcc-3c527a35fa428b727807c81f1225a5e0025446c1.tar.gz gcc-3c527a35fa428b727807c81f1225a5e0025446c1.tar.bz2 |
Merge branch 'master' into devel/sphinx
Diffstat (limited to 'libstdc++-v3')
67 files changed, 894 insertions, 208 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a55293e..e6722cf 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,207 @@ +2022-09-24 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/alloc_traits.h (allocator_traits::is_always_equal): + Only instantiate is_empty if needed. + * include/bits/ptr_traits.h (__ptr_traits_impl::difference_type) + (__ptr_traits_impl::rebind): Use __detected_or. + * include/experimental/type_traits (is_same_v): Add a partial + specialization instead of instantiating the std::is_same class + template. + (detected_t): Redefine in terms of detected_or_t. + (is_detected, is_detected_v): Redefine in terms of detected_t. + * include/std/type_traits [__cpp_concepts] (__detected_or): Add + new definition using concepts. + (__detector::value_t): Rename to __is_detected. + * testsuite/17_intro/names.cc: Check value_t isn't used. + +2022-09-23 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/20_util/is_assignable/requirements/access.cc: + New test. + +2022-09-23 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/91456 + * include/std/type_traits (__is_nothrow_invocable_lib): Remove. + (__is_invocable_impl::__nothrow_type): New member type which + checks if the conversion can throw. + (__is_nt_invocable_impl): Replace class template with alias + template to __is_nt_invocable_impl::__nothrow_type. + * testsuite/20_util/is_nothrow_invocable/91456.cc: New test. + * testsuite/20_util/is_nothrow_convertible/value.cc: Remove + macro used by value_ext.cc test. + * testsuite/20_util/is_nothrow_convertible/value_ext.cc: Remove + test for non-standard __is_nothrow_invocable_lib trait. + +2022-09-23 Marek Polacek <polacek@redhat.com> + + PR c++/106784 + * include/std/type_traits: Rename __is_nothrow_convertible to + __is_nothrow_convertible_lib. + * testsuite/20_util/is_nothrow_convertible/value_ext.cc: Likewise. + +2022-09-23 Jonathan Wakely <jwakely@redhat.com> + + * include/std/bitset (operator>>): Do not copy for N==0. + * testsuite/20_util/bitset/io/input.cc: Add comment. + +2022-09-23 Jonathan Wakely <jwakely@redhat.com> + + * include/debug/bitset (__debug::bitset): Add constexpr to all + member functions. + (operator&, operator|, operator^): Add inline and constexpr. + (operator>>, operator<<): Add inline. + * testsuite/20_util/bitset/access/constexpr.cc: Only check using + constexpr std::string for the cxx11 ABI. + * testsuite/20_util/bitset/cons/constexpr_c++23.cc: Likewise. + * testsuite/20_util/headers/bitset/synopsis.cc: Check constexpr + for C++23. + +2022-09-23 Jonathan Wakely <jwakely@redhat.com> + + * include/std/bitset (bitset::_M_copy_to_string): Find set bits + instead of iterating over individual bits. + +2022-09-22 Jonathan Wakely <jwakely@redhat.com> + + * include/std/bitset (bitset): Add constexpr for C++23. Guard + members using std::string with _GLIBCXX_HOSTED. + * include/std/version (__cpp_lib_constexpr_bitset): Define. + * testsuite/20_util/bitset/access/constexpr.cc: New test. + * testsuite/20_util/bitset/cons/constexpr_c++23.cc: New test. + * testsuite/20_util/bitset/count/constexpr.cc: New test. + * testsuite/20_util/bitset/ext/constexpr.cc: New test. + * testsuite/20_util/bitset/operations/constexpr_c++23.cc: New test. + * testsuite/20_util/bitset/version.cc: New test. + +2022-09-22 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/23_containers/bitset/18604.cc: Moved to... + * testsuite/20_util/bitset/18604.cc: ...here. + * testsuite/23_containers/bitset/45713.cc: Moved to... + * testsuite/20_util/bitset/45713.cc: ...here. + * testsuite/23_containers/bitset/to_string/dr396.cc: Moved to... + * testsuite/20_util/bitset/access/dr396.cc: ...here. + * testsuite/23_containers/bitset/to_string/1.cc: Moved to... + * testsuite/20_util/bitset/access/to_string.cc: ...here. + * testsuite/23_containers/bitset/to_ullong/1.cc: Moved to... + * testsuite/20_util/bitset/access/to_ullong.cc: ...here. + * testsuite/23_containers/bitset/to_ulong/1.cc: Moved to... + * testsuite/20_util/bitset/access/to_ulong.cc: ...here. + * testsuite/23_containers/bitset/cons/1.cc: Moved to... + * testsuite/20_util/bitset/cons/1.cc: ...here. + * testsuite/23_containers/bitset/cons/16020.cc: Moved to... + * testsuite/20_util/bitset/cons/16020.cc: ...here. + * testsuite/23_containers/bitset/cons/2.cc: Moved to... + * testsuite/20_util/bitset/cons/2.cc: ...here. + * testsuite/23_containers/bitset/cons/3.cc: Moved to... + * testsuite/20_util/bitset/cons/3.cc: ...here. + * testsuite/23_containers/bitset/cons/38244.cc: Moved to... + * testsuite/20_util/bitset/cons/38244.cc: ...here. + * testsuite/23_containers/bitset/cons/50268.cc: Moved to... + * testsuite/20_util/bitset/cons/50268.cc: ...here. + * testsuite/23_containers/bitset/cons/6282.cc: Moved to... + * testsuite/20_util/bitset/cons/6282.cc: ...here. + * testsuite/23_containers/bitset/cons/constexpr.cc: Moved to... + * testsuite/20_util/bitset/cons/constexpr.cc: ...here. + * testsuite/23_containers/bitset/cons/dr1325-1.cc: Moved to... + * testsuite/20_util/bitset/cons/dr1325-1.cc: ...here. + * testsuite/23_containers/bitset/cons/dr1325-2.cc: Moved to... + * testsuite/20_util/bitset/cons/dr1325-2.cc: ...here. + * testsuite/23_containers/bitset/cons/dr396.cc: Moved to... + * testsuite/20_util/bitset/cons/dr396.cc: ...here. + * testsuite/23_containers/bitset/debug/invalidation/1.cc: Moved to... + * testsuite/20_util/bitset/debug/invalidation/1.cc: ...here. + * testsuite/23_containers/bitset/ext/15361.cc: Moved to... + * testsuite/20_util/bitset/ext/15361.cc: ...here. + * testsuite/23_containers/bitset/hash/1.cc: Moved to... + * testsuite/20_util/bitset/hash/1.cc: ...here. + * testsuite/23_containers/bitset/input/1.cc: Moved to... + * testsuite/20_util/bitset/io/input.cc: ...here. + * testsuite/23_containers/bitset/count/6124.cc: Moved to... + * testsuite/20_util/bitset/observers/6124.cc: ...here. + * testsuite/23_containers/bitset/all/1.cc: Moved to... + * testsuite/20_util/bitset/observers/all.cc: ...here. + * testsuite/23_containers/bitset/test/1.cc: Moved to... + * testsuite/20_util/bitset/observers/test.cc: ...here. + * testsuite/23_containers/bitset/operations/1.cc: Moved to... + * testsuite/20_util/bitset/operations/1.cc: ...here. + * testsuite/23_containers/bitset/operations/13838.cc: Moved to... + * testsuite/20_util/bitset/operations/13838.cc: ...here. + * testsuite/23_containers/bitset/operations/2.cc: Moved to... + * testsuite/20_util/bitset/operations/2.cc: ...here. + * testsuite/23_containers/bitset/operations/96303.cc: Moved to... + * testsuite/20_util/bitset/operations/96303.cc: ...here. + * testsuite/23_containers/bitset/operations/constexpr-2.cc: Moved to... + * testsuite/20_util/bitset/operations/constexpr-2.cc: ...here. + * testsuite/23_containers/bitset/operations/constexpr.cc: Moved to... + * testsuite/20_util/bitset/operations/constexpr.cc: ...here. + * testsuite/23_containers/bitset/requirements/constexpr_functions.cc: Moved to... + * testsuite/20_util/bitset/requirements/constexpr_functions.cc: ...here. + * testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc: Moved to... + * testsuite/20_util/bitset/requirements/explicit_instantiation/1.cc: ...here. + * testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc: Moved to... + * testsuite/20_util/bitset/requirements/explicit_instantiation/1_c++0x.cc: ...here. + * testsuite/23_containers/headers/bitset/synopsis.cc: Moved to... + * testsuite/20_util/headers/bitset/synopsis.cc: ...here. + +2022-09-22 François Dumont <fdumont@gcc.gnu.org> + + * python/libstdcxx/v6/printers.py: Remove ptinter registration for non-existing + types std::__debug::unique_ptr, std::__debug::stack, std::__debug::queue, + std::__debug::priority_queue. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/91456 + * testsuite/20_util/function/91456.cc: Add comment with PR + number. + * testsuite/20_util/is_invocable/91456.cc: Likewise. Replace + std::function checks with std::is_invocable_r checks. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/17_intro/headers/c++1998/all_attributes.cc: Remove + unnecessary main function. + * testsuite/17_intro/headers/c++2011/all_attributes.cc: + Likewise. + * testsuite/17_intro/headers/c++2014/all_attributes.cc: + Likewise. + * testsuite/17_intro/headers/c++2017/all_attributes.cc: + Likewise. + * testsuite/17_intro/headers/c++2020/all_attributes.cc: + Likewise. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/20_util/headers/memory/synopsis.cc: Add declarations + from C++11 and later. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + * doc/xml/manual/documentation_hacking.xml: Remove trailing + whitespace. + * doc/xml/manual/policy_data_structures.xml: Likewise. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + * include/c_compatibility/stdlib.h [!_GLIBCXX_HOSTED]: Add + using-declaration for _Exit. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + * testsuite/18_support/uncaught_exception/14026.cc: Qualify + call to std::abort. + +2022-09-21 Jonathan Wakely <jwakely@redhat.com> + + * include/bits/ranges_base.h: Include <initializer_list>. + +2022-09-20 Jonathan Wakely <jwakely@redhat.com> + + * include/c_global/cstdlib [!_GLIBCXX_HOSTED] (quick_exit): Fix + missing space. + 2022-09-16 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/106953 diff --git a/libstdc++-v3/doc/xml/manual/documentation_hacking.xml b/libstdc++-v3/doc/xml/manual/documentation_hacking.xml index 03bf1f1..776d5e8 100644 --- a/libstdc++-v3/doc/xml/manual/documentation_hacking.xml +++ b/libstdc++-v3/doc/xml/manual/documentation_hacking.xml @@ -353,7 +353,7 @@ documentation. Here are some of the obvious errors, and ways to fix some common issues that may appear quite cryptic. </para> - + <para> First, if using a rule like <code>make pdf</code>, try to narrow down the scope of the error to either docbook @@ -844,7 +844,7 @@ make <literal>XSL_STYLE_DIR="/usr/share/xml/docbook/stylesheet/nwalsh"</literal> documentation. Here are some of the obvious errors, and ways to fix some common issues that may appear quite cryptic. </para> - + <para> First, if using a rule like <code>make pdf</code>, try to narrow down the scope of the error to either docbook diff --git a/libstdc++-v3/doc/xml/manual/policy_data_structures.xml b/libstdc++-v3/doc/xml/manual/policy_data_structures.xml index 3e59810..305257c 100644 --- a/libstdc++-v3/doc/xml/manual/policy_data_structures.xml +++ b/libstdc++-v3/doc/xml/manual/policy_data_structures.xml @@ -3003,7 +3003,7 @@ </textobject> </mediaobject> </figure> - + <para>Let U be a domain (e.g., the integers, or the strings of 3 characters). A hash-table algorithm needs to map elements of U "uniformly" into the range [0,..., m - @@ -3179,7 +3179,7 @@ 0</subscript><superscript>t - 1</superscript> s<subscript>i</subscript> a<superscript>i</superscript> mod m </mathphrase> </equation> - + <para>where a is some non-negative integral value. This is the standard string-hashing function used in SGI's @@ -3278,7 +3278,7 @@ </textobject> </mediaobject> </figure> - + <para>If <classname>cc_hash_table</classname>'s hash-functor, <classname>Hash_Fn</classname> is instantiated by <classname>null_type</classname> , then <classname>Comb_Hash_Fn</classname> is taken to be a ranged-hash function. The graphic below shows an <function>insert</function> sequence @@ -3298,7 +3298,7 @@ </textobject> </mediaobject> </figure> - + </section> <section xml:id="hash_policies.implementation.probe"> @@ -3917,7 +3917,7 @@ </textobject> </mediaobject> </figure> - + <para>Supporting such trees is difficult for a number of reasons:</para> @@ -4819,7 +4819,7 @@ assert(p.top() == 3); </programlisting> - + <para>It should be noted that an alternative design could embed an associative container in a priority queue. Could, but most probably should not. To begin with, it should be noted that one diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h index 507e8f1..8479bfd 100644 --- a/libstdc++-v3/include/bits/alloc_traits.h +++ b/libstdc++-v3/include/bits/alloc_traits.h @@ -74,7 +74,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<typename _Tp> using __pocs = typename _Tp::propagate_on_container_swap; template<typename _Tp> - using __equal = typename _Tp::is_always_equal; + using __equal = __type_identity<typename _Tp::is_always_equal>; }; template<typename _Alloc, typename _Up> @@ -209,7 +209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * otherwise @c is_empty<Alloc>::type */ using is_always_equal - = __detected_or_t<typename is_empty<_Alloc>::type, __equal, _Alloc>; + = typename __detected_or_t<is_empty<_Alloc>, __equal, _Alloc>::type; template<typename _Tp> using rebind_alloc = __alloc_rebind<_Alloc, _Tp>; diff --git a/libstdc++-v3/include/bits/ptr_traits.h b/libstdc++-v3/include/bits/ptr_traits.h index 8360c3b..ae88107 100644 --- a/libstdc++-v3/include/bits/ptr_traits.h +++ b/libstdc++-v3/include/bits/ptr_traits.h @@ -144,29 +144,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __ptr_traits_impl : __ptr_traits_ptr_to<_Ptr, _Elt> { private: - template<typename _Tp, typename = void> - struct __difference { using type = ptrdiff_t; }; - template<typename _Tp> -#if __cpp_concepts - requires requires { typename _Tp::difference_type; } - struct __difference<_Tp> -#else - struct __difference<_Tp, __void_t<typename _Tp::difference_type>> -#endif - { using type = typename _Tp::difference_type; }; - - template<typename _Tp, typename _Up, typename = void> - struct __rebind : __replace_first_arg<_Tp, _Up> { }; + using __diff_t = typename _Tp::difference_type; template<typename _Tp, typename _Up> -#if __cpp_concepts - requires requires { typename _Tp::template rebind<_Up>; } - struct __rebind<_Tp, _Up> -#else - struct __rebind<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>>> -#endif - { using type = typename _Tp::template rebind<_Up>; }; + using __rebind = __type_identity<typename _Tp::template rebind<_Up>>; public: /// The pointer type. @@ -176,11 +158,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using element_type = _Elt; /// The type used to represent the difference between two pointers. - using difference_type = typename __difference<_Ptr>::type; + using difference_type = __detected_or_t<ptrdiff_t, __diff_t, _Ptr>; /// A pointer to a different type. template<typename _Up> - using rebind = typename __rebind<_Ptr, _Up>::type; + using rebind = typename __detected_or_t<__replace_first_arg<_Ptr, _Up>, + __rebind, _Ptr, _Up>::type; }; // _GLIBCXX_RESOLVE_LIB_DEFECTS diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 866d7c5..805f196 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -33,6 +33,7 @@ #pragma GCC system_header #if __cplusplus > 201703L +#include <initializer_list> #include <bits/iterator_concepts.h> #include <ext/numeric_traits.h> #include <bits/max_size_type.h> diff --git a/libstdc++-v3/include/c_compatibility/stdlib.h b/libstdc++-v3/include/c_compatibility/stdlib.h index 377b910..70fa4c8 100644 --- a/libstdc++-v3/include/c_compatibility/stdlib.h +++ b/libstdc++-v3/include/c_compatibility/stdlib.h @@ -45,6 +45,9 @@ using std::exit; # ifdef _GLIBCXX_HAVE_QUICK_EXIT using std::quick_exit; # endif +# if _GLIBCXX_USE_C99_STDLIB + using std::_Exit; +# endif #endif #if _GLIBCXX_HOSTED diff --git a/libstdc++-v3/include/debug/bitset b/libstdc++-v3/include/debug/bitset index 4c0af03..9335fe4 100644 --- a/libstdc++-v3/include/debug/bitset +++ b/libstdc++-v3/include/debug/bitset @@ -141,6 +141,7 @@ namespace __debug : _Base(__val) { } template<typename _CharT, typename _Traits, typename _Alloc> + _GLIBCXX23_CONSTEXPR explicit bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str, typename std::basic_string<_CharT, _Traits, _Alloc>::size_type @@ -152,6 +153,7 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __str, typename std::basic_string<_CharT, _Traits, _Alloc>::size_type __pos, @@ -160,10 +162,12 @@ namespace __debug _CharT __zero, _CharT __one = _CharT('1')) : _Base(__str, __pos, __n, __zero, __one) { } + _GLIBCXX23_CONSTEXPR bitset(const _Base& __x) : _Base(__x) { } #if __cplusplus >= 201103L template<typename _CharT> + _GLIBCXX23_CONSTEXPR explicit bitset(const _CharT* __str, typename std::basic_string<_CharT>::size_type __n @@ -173,6 +177,7 @@ namespace __debug #endif // 23.3.5.2 bitset operations: + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { @@ -180,6 +185,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { @@ -187,6 +193,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { @@ -194,6 +201,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator<<=(size_t __pos) _GLIBCXX_NOEXCEPT { @@ -201,6 +209,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator>>=(size_t __pos) _GLIBCXX_NOEXCEPT { @@ -208,6 +217,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& set() _GLIBCXX_NOEXCEPT { @@ -217,6 +227,7 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 186. bitset::set() second parameter should be bool + _GLIBCXX23_CONSTEXPR bitset<_Nb>& set(size_t __pos, bool __val = true) { @@ -224,6 +235,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& reset() _GLIBCXX_NOEXCEPT { @@ -231,6 +243,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& reset(size_t __pos) { @@ -238,10 +251,12 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb> operator~() const _GLIBCXX_NOEXCEPT { return bitset(~_M_base()); } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& flip() _GLIBCXX_NOEXCEPT { @@ -249,6 +264,7 @@ namespace __debug return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& flip(size_t __pos) { @@ -259,6 +275,7 @@ namespace __debug // element access: // _GLIBCXX_RESOLVE_LIB_DEFECTS // 11. Bitset minor problems + _GLIBCXX23_CONSTEXPR reference operator[](size_t __pos) { @@ -288,6 +305,7 @@ namespace __debug #endif template <typename _CharT, typename _Traits, typename _Alloc> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, _Alloc> to_string() const { return _M_base().template to_string<_CharT, _Traits, _Alloc>(); } @@ -295,6 +313,7 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, _Alloc> to_string(_CharT __zero, _CharT __one = _CharT('1')) const { @@ -305,6 +324,7 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 434. bitset::to_string() hard to use. template<typename _CharT, typename _Traits> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string() const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } @@ -312,12 +332,14 @@ namespace __debug // _GLIBCXX_RESOLVE_LIB_DEFECTS // 853. to_string needs updating with zero and one. template<class _CharT, class _Traits> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(__zero, __one); } template<typename _CharT> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string() const @@ -327,6 +349,7 @@ namespace __debug } template<class _CharT> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const @@ -335,12 +358,14 @@ namespace __debug std::allocator<_CharT> >(__zero, __one); } + _GLIBCXX23_CONSTEXPR std::basic_string<char, std::char_traits<char>, std::allocator<char> > to_string() const { return to_string<char,std::char_traits<char>,std::allocator<char> >(); } + _GLIBCXX23_CONSTEXPR std::basic_string<char, std::char_traits<char>, std::allocator<char> > to_string(char __zero, char __one = '1') const { @@ -351,6 +376,7 @@ namespace __debug using _Base::count; using _Base::size; + _GLIBCXX23_CONSTEXPR bool operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return _M_base() == __rhs._M_base(); } @@ -366,45 +392,52 @@ namespace __debug using _Base::any; using _Base::none; + _GLIBCXX23_CONSTEXPR bitset<_Nb> operator<<(size_t __pos) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(_M_base() << __pos); } + _GLIBCXX23_CONSTEXPR bitset<_Nb> operator>>(size_t __pos) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(_M_base() >> __pos); } + _GLIBCXX23_CONSTEXPR _Base& _M_base() _GLIBCXX_NOEXCEPT { return *this; } + _GLIBCXX23_CONSTEXPR const _Base& _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; template<size_t _Nb> - bitset<_Nb> + _GLIBCXX23_CONSTEXPR + inline bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { return bitset<_Nb>(__x) &= __y; } template<size_t _Nb> - bitset<_Nb> + _GLIBCXX23_CONSTEXPR + inline bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { return bitset<_Nb>(__x) |= __y; } template<size_t _Nb> - bitset<_Nb> + _GLIBCXX23_CONSTEXPR + inline bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { return bitset<_Nb>(__x) ^= __y; } template<typename _CharT, typename _Traits, size_t _Nb> - std::basic_istream<_CharT, _Traits>& + inline std::basic_istream<_CharT, _Traits>& operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x) { return __is >> __x._M_base(); } template<typename _CharT, typename _Traits, size_t _Nb> - std::basic_ostream<_CharT, _Traits>& + inline std::basic_ostream<_CharT, _Traits>& operator<<(std::basic_ostream<_CharT, _Traits>& __os, const bitset<_Nb>& __x) { return __os << __x._M_base(); } diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits index af5970e..fa25a1c 100644 --- a/libstdc++-v3/include/experimental/type_traits +++ b/libstdc++-v3/include/experimental/type_traits @@ -223,7 +223,9 @@ template <typename _Tp, unsigned _Idx = 0> // See C++14 20.10.6, type relations template <typename _Tp, typename _Up> - constexpr bool is_same_v = is_same<_Tp, _Up>::value; + constexpr bool is_same_v = false; +template <typename _Tp> + constexpr bool is_same_v<_Tp, _Tp> = true; template <typename _Base, typename _Derived> constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; template <typename _From, typename _To> @@ -266,23 +268,21 @@ struct nonesuch : private __nonesuchbase }; #pragma GCC diagnostic pop -template<template<typename...> class _Op, typename... _Args> - using is_detected - = typename std::__detector<nonesuch, void, _Op, _Args...>::value_t; - -template<template<typename...> class _Op, typename... _Args> - constexpr bool is_detected_v = is_detected<_Op, _Args...>::value; - -template<template<typename...> class _Op, typename... _Args> - using detected_t - = typename std::__detector<nonesuch, void, _Op, _Args...>::type; - template<typename _Default, template<typename...> class _Op, typename... _Args> using detected_or = std::__detected_or<_Default, _Op, _Args...>; template<typename _Default, template<typename...> class _Op, typename... _Args> using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type; +template<template<typename...> class _Op, typename... _Args> + using detected_t = detected_or_t<nonesuch, _Op, _Args...>; + +template<template<typename...> class _Op, typename... _Args> + using is_detected = typename detected_or<void, _Op, _Args...>::__is_detected; + +template<template<typename...> class _Op, typename... _Args> + constexpr bool is_detected_v = is_detected<_Op, _Args...>::value; + template<typename _Expected, template<typename...> class _Op, typename... _Args> using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>; diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset index 438c2f7..1a551cf 100644 --- a/libstdc++-v3/include/std/bitset +++ b/libstdc++-v3/include/std/bitset @@ -44,14 +44,15 @@ #pragma GCC system_header -#include <string> #include <bits/functexcept.h> // For invalid_argument, out_of_range, // overflow_error -#include <iosfwd> -#include <bits/cxxabi_forced.h> - -#if __cplusplus >= 201103L -# include <bits/functional_hash.h> +#if _GLIBCXX_HOSTED +# include <string> +# include <iosfwd> +# include <bits/cxxabi_forced.h> +# if __cplusplus >= 201103L +# include <bits/functional_hash.h> +# endif #endif #define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * __SIZEOF_LONG__) @@ -65,6 +66,10 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_CONTAINER +#if __cplusplus > 202002L && _GLIBCXX_HOSTED +# define __cpp_lib_constexpr_bitset 202202L +#endif + /** * Base class, general case. It is a class invariant that _Nw will be * nonnegative. @@ -111,7 +116,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } - _WordT& + _GLIBCXX14_CONSTEXPR _WordT& _M_getword(size_t __pos) _GLIBCXX_NOEXCEPT { return _M_w[_S_whichword(__pos)]; } @@ -120,12 +125,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { return _M_w[_S_whichword(__pos)]; } #if __cplusplus >= 201103L - const _WordT* + constexpr const _WordT* _M_getdata() const noexcept { return _M_w; } #endif - _WordT& + _GLIBCXX23_CONSTEXPR _WordT& _M_hiword() _GLIBCXX_NOEXCEPT { return _M_w[_Nw - 1]; } @@ -133,52 +138,62 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_hiword() const _GLIBCXX_NOEXCEPT { return _M_w[_Nw - 1]; } - void + _GLIBCXX23_CONSTEXPR void _M_do_and(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] &= __x._M_w[__i]; } - void + _GLIBCXX14_CONSTEXPR void _M_do_or(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] |= __x._M_w[__i]; } - void + _GLIBCXX14_CONSTEXPR void _M_do_xor(const _Base_bitset<_Nw>& __x) _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] ^= __x._M_w[__i]; } - void + _GLIBCXX14_CONSTEXPR void _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT; - void + _GLIBCXX14_CONSTEXPR void _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT; - void + _GLIBCXX14_CONSTEXPR void _M_do_flip() _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] = ~_M_w[__i]; } - void + _GLIBCXX14_CONSTEXPR void _M_do_set() _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) _M_w[__i] = ~static_cast<_WordT>(0); } - void + _GLIBCXX14_CONSTEXPR void _M_do_reset() _GLIBCXX_NOEXCEPT - { __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); } + { +#if __cplusplus >= 201402L + if (__builtin_is_constant_evaluated()) + { + for (_WordT& __w : _M_w) + __w = 0; + return; + } +#endif + __builtin_memset(_M_w, 0, _Nw * sizeof(_WordT)); + } - bool + _GLIBCXX14_CONSTEXPR bool _M_is_equal(const _Base_bitset<_Nw>& __x) const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; ++__i) @@ -188,7 +203,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<size_t _Nb> - bool + _GLIBCXX14_CONSTEXPR bool _M_are_all() const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw - 1; __i++) @@ -199,7 +214,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER - _Nb)); } - bool + _GLIBCXX14_CONSTEXPR bool _M_is_any() const _GLIBCXX_NOEXCEPT { for (size_t __i = 0; __i < _Nw; __i++) @@ -208,7 +223,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return false; } - size_t + _GLIBCXX14_CONSTEXPR size_t _M_do_count() const _GLIBCXX_NOEXCEPT { size_t __result = 0; @@ -217,26 +232,26 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __result; } - unsigned long + _GLIBCXX14_CONSTEXPR unsigned long _M_do_to_ulong() const; #if __cplusplus >= 201103L - unsigned long long + _GLIBCXX14_CONSTEXPR unsigned long long _M_do_to_ullong() const; #endif // find first "on" bit - size_t + _GLIBCXX14_CONSTEXPR size_t _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT; // find the next "on" bit that follows "prev" - size_t + _GLIBCXX14_CONSTEXPR size_t _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT; }; // Definitions of non-inline functions from _Base_bitset. template<size_t _Nw> - void + _GLIBCXX14_CONSTEXPR void _Base_bitset<_Nw>::_M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT { if (__builtin_expect(__shift != 0, 1)) @@ -262,7 +277,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<size_t _Nw> - void + _GLIBCXX14_CONSTEXPR void _Base_bitset<_Nw>::_M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT { if (__builtin_expect(__shift != 0, 1)) @@ -289,7 +304,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<size_t _Nw> - unsigned long + _GLIBCXX14_CONSTEXPR unsigned long _Base_bitset<_Nw>::_M_do_to_ulong() const { for (size_t __i = 1; __i < _Nw; ++__i) @@ -300,7 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L template<size_t _Nw> - unsigned long long + _GLIBCXX14_CONSTEXPR unsigned long long _Base_bitset<_Nw>::_M_do_to_ullong() const { const bool __dw = sizeof(unsigned long long) > sizeof(unsigned long); @@ -316,7 +331,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #endif template<size_t _Nw> - size_t + _GLIBCXX14_CONSTEXPR size_t _Base_bitset<_Nw>:: _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT { @@ -332,7 +347,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<size_t _Nw> - size_t + _GLIBCXX14_CONSTEXPR size_t _Base_bitset<_Nw>:: _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT { @@ -406,7 +421,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _S_maskbit(size_t __pos) _GLIBCXX_NOEXCEPT { return (static_cast<_WordT>(1)) << _S_whichbit(__pos); } - _WordT& + _GLIBCXX14_CONSTEXPR _WordT& _M_getword(size_t) _GLIBCXX_NOEXCEPT { return _M_w; } @@ -415,12 +430,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { return _M_w; } #if __cplusplus >= 201103L - const _WordT* + constexpr const _WordT* _M_getdata() const noexcept { return &_M_w; } #endif - _WordT& + _GLIBCXX14_CONSTEXPR _WordT& _M_hiword() _GLIBCXX_NOEXCEPT { return _M_w; } @@ -428,67 +443,67 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_hiword() const _GLIBCXX_NOEXCEPT { return _M_w; } - void + _GLIBCXX14_CONSTEXPR void _M_do_and(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT { _M_w &= __x._M_w; } - void + _GLIBCXX14_CONSTEXPR void _M_do_or(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT { _M_w |= __x._M_w; } - void + _GLIBCXX14_CONSTEXPR void _M_do_xor(const _Base_bitset<1>& __x) _GLIBCXX_NOEXCEPT { _M_w ^= __x._M_w; } - void + _GLIBCXX14_CONSTEXPR void _M_do_left_shift(size_t __shift) _GLIBCXX_NOEXCEPT { _M_w <<= __shift; } - void + _GLIBCXX14_CONSTEXPR void _M_do_right_shift(size_t __shift) _GLIBCXX_NOEXCEPT { _M_w >>= __shift; } - void + _GLIBCXX14_CONSTEXPR void _M_do_flip() _GLIBCXX_NOEXCEPT { _M_w = ~_M_w; } - void + _GLIBCXX14_CONSTEXPR void _M_do_set() _GLIBCXX_NOEXCEPT { _M_w = ~static_cast<_WordT>(0); } - void + _GLIBCXX14_CONSTEXPR void _M_do_reset() _GLIBCXX_NOEXCEPT { _M_w = 0; } - bool + _GLIBCXX14_CONSTEXPR bool _M_is_equal(const _Base_bitset<1>& __x) const _GLIBCXX_NOEXCEPT { return _M_w == __x._M_w; } template<size_t _Nb> - bool + _GLIBCXX14_CONSTEXPR bool _M_are_all() const _GLIBCXX_NOEXCEPT { return _M_w == (~static_cast<_WordT>(0) >> (_GLIBCXX_BITSET_BITS_PER_WORD - _Nb)); } - bool + _GLIBCXX14_CONSTEXPR bool _M_is_any() const _GLIBCXX_NOEXCEPT { return _M_w != 0; } - size_t + _GLIBCXX14_CONSTEXPR size_t _M_do_count() const _GLIBCXX_NOEXCEPT { return __builtin_popcountl(_M_w); } - unsigned long + _GLIBCXX14_CONSTEXPR unsigned long _M_do_to_ulong() const _GLIBCXX_NOEXCEPT { return _M_w; } #if __cplusplus >= 201103L - unsigned long long + constexpr unsigned long long _M_do_to_ullong() const noexcept { return _M_w; } #endif - size_t + _GLIBCXX14_CONSTEXPR size_t _M_do_find_first(size_t __not_found) const _GLIBCXX_NOEXCEPT { if (_M_w != 0) @@ -498,7 +513,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } // find the next "on" bit that follows "prev" - size_t + _GLIBCXX14_CONSTEXPR size_t _M_do_find_next(size_t __prev, size_t __not_found) const _GLIBCXX_NOEXCEPT { @@ -552,17 +567,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // This would normally give access to the data. The bounds-checking // in the bitset class will prevent the user from getting this far, - // but (1) it must still return an lvalue to compile, and (2) the - // user might call _Unchecked_set directly, in which case this /needs/ - // to fail. Let's not penalize zero-length users unless they actually + // but this must fail if the user calls _Unchecked_set directly. + // Let's not penalize zero-length users unless they actually // make an unchecked call; all the memory ugliness is therefore // localized to this single should-never-get-this-far function. + __attribute__((__noreturn__)) _WordT& _M_getword(size_t) _GLIBCXX_NOEXCEPT - { - __throw_out_of_range(__N("_Base_bitset::_M_getword")); - return *new _WordT; - } + { __throw_out_of_range(__N("_Base_bitset::_M_getword")); } _GLIBCXX_CONSTEXPR _WordT _M_getword(size_t) const _GLIBCXX_NOEXCEPT @@ -572,75 +584,75 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _M_hiword() const _GLIBCXX_NOEXCEPT { return 0; } - void + _GLIBCXX14_CONSTEXPR void _M_do_and(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_or(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_xor(const _Base_bitset<0>&) _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_left_shift(size_t) _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_right_shift(size_t) _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_flip() _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_set() _GLIBCXX_NOEXCEPT { } - void + _GLIBCXX14_CONSTEXPR void _M_do_reset() _GLIBCXX_NOEXCEPT { } // Are all empty bitsets equal to each other? Are they equal to // themselves? How to compare a thing which has no state? What is // the sound of one zero-length bitset clapping? - bool + _GLIBCXX_CONSTEXPR bool _M_is_equal(const _Base_bitset<0>&) const _GLIBCXX_NOEXCEPT { return true; } template<size_t _Nb> - bool + _GLIBCXX_CONSTEXPR bool _M_are_all() const _GLIBCXX_NOEXCEPT { return true; } - bool + _GLIBCXX_CONSTEXPR bool _M_is_any() const _GLIBCXX_NOEXCEPT { return false; } - size_t + _GLIBCXX_CONSTEXPR size_t _M_do_count() const _GLIBCXX_NOEXCEPT { return 0; } - unsigned long + _GLIBCXX_CONSTEXPR unsigned long _M_do_to_ulong() const _GLIBCXX_NOEXCEPT { return 0; } #if __cplusplus >= 201103L - unsigned long long + constexpr unsigned long long _M_do_to_ullong() const noexcept { return 0; } #endif // Normally "not found" is the size, but that could also be // misinterpreted as an index in this corner case. Oh well. - size_t + _GLIBCXX_CONSTEXPR size_t _M_do_find_first(size_t) const _GLIBCXX_NOEXCEPT { return 0; } - size_t + _GLIBCXX_CONSTEXPR size_t _M_do_find_next(size_t, size_t) const _GLIBCXX_NOEXCEPT { return 0; } }; @@ -652,7 +664,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { typedef unsigned long _WordT; - static void + static _GLIBCXX14_CONSTEXPR void _S_do_sanitize(_WordT& __val) _GLIBCXX_NOEXCEPT { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); } }; @@ -662,7 +674,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { typedef unsigned long _WordT; - static void + static _GLIBCXX14_CONSTEXPR void _S_do_sanitize(_WordT) _GLIBCXX_NOEXCEPT { } }; @@ -755,7 +767,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base; typedef unsigned long _WordT; +#if _GLIBCXX_HOSTED template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR void _M_check_initial_position(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position) const @@ -766,7 +780,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER "(which is %zu)"), __position, __s.size()); } +#endif // HOSTED + _GLIBCXX23_CONSTEXPR void _M_check(size_t __position, const char *__s) const { if (__position >= _Nb) @@ -775,6 +791,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __s, __position, _Nb); } + _GLIBCXX23_CONSTEXPR void _M_do_sanitize() _GLIBCXX_NOEXCEPT { @@ -810,6 +827,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER reference(); public: + _GLIBCXX23_CONSTEXPR reference(bitset& __b, size_t __pos) _GLIBCXX_NOEXCEPT { _M_wp = &__b._M_getword(__pos); @@ -820,10 +838,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER reference(const reference&) = default; #endif +#if __cplusplus > 202002L && __cpp_constexpr_dynamic_alloc + constexpr +#endif ~reference() _GLIBCXX_NOEXCEPT { } // For b[i] = __x; + _GLIBCXX23_CONSTEXPR reference& operator=(bool __x) _GLIBCXX_NOEXCEPT { @@ -835,6 +857,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } // For b[i] = b[__j]; + _GLIBCXX23_CONSTEXPR reference& operator=(const reference& __j) _GLIBCXX_NOEXCEPT { @@ -846,15 +869,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } // Flips the bit + _GLIBCXX23_CONSTEXPR bool operator~() const _GLIBCXX_NOEXCEPT { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) == 0; } // For __x = b[i]; + _GLIBCXX23_CONSTEXPR operator bool() const _GLIBCXX_NOEXCEPT { return (*(_M_wp) & _Base::_S_maskbit(_M_bpos)) != 0; } // For b[i].flip(); + _GLIBCXX23_CONSTEXPR reference& flip() _GLIBCXX_NOEXCEPT { @@ -879,6 +905,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { _M_do_sanitize(); } #endif +#if _GLIBCXX_HOSTED /** * Use a subset of a string. * @param __s A string of @a 0 and @a 1 characters. @@ -889,6 +916,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * which is neither @a 0 nor @a 1. */ template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR explicit bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position = 0) @@ -911,6 +939,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * which is neither @a 0 nor @a 1. */ template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position, size_t __n) : _Base() @@ -922,6 +951,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR bitset(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __position, size_t __n, _CharT __zero, _CharT __one = _CharT('1')) @@ -942,6 +972,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * which is neither @a __zero nor @a __one. */ template<typename _CharT> + [[__gnu__::__nonnull__]] + _GLIBCXX23_CONSTEXPR explicit bitset(const _CharT* __str, typename std::basic_string<_CharT>::size_type __n @@ -958,7 +990,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __n, __zero, __one); } -#endif +#endif // C++11 +#endif // HOSTED // 23.3.5.2 bitset operations: ///@{ @@ -968,6 +1001,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * These should be self-explanatory. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator&=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { @@ -975,6 +1009,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator|=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { @@ -982,6 +1017,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator^=(const bitset<_Nb>& __rhs) _GLIBCXX_NOEXCEPT { @@ -997,6 +1033,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * These should be self-explanatory. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator<<=(size_t __position) _GLIBCXX_NOEXCEPT { @@ -1010,6 +1047,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& operator>>=(size_t __position) _GLIBCXX_NOEXCEPT { @@ -1030,6 +1068,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * extensions from the SGI version. They do no range checking. * @ingroup SGIextensions */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& _Unchecked_set(size_t __pos) _GLIBCXX_NOEXCEPT { @@ -1037,6 +1076,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& _Unchecked_set(size_t __pos, int __val) _GLIBCXX_NOEXCEPT { @@ -1047,6 +1087,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& _Unchecked_reset(size_t __pos) _GLIBCXX_NOEXCEPT { @@ -1054,6 +1095,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return *this; } + _GLIBCXX23_CONSTEXPR bitset<_Nb>& _Unchecked_flip(size_t __pos) _GLIBCXX_NOEXCEPT { @@ -1071,6 +1113,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** * @brief Sets every bit to true. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& set() _GLIBCXX_NOEXCEPT { @@ -1085,6 +1128,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @param __val Either true or false, defaults to true. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& set(size_t __position, bool __val = true) { @@ -1095,6 +1139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** * @brief Sets every bit to false. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& reset() _GLIBCXX_NOEXCEPT { @@ -1109,6 +1154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * * Same as writing @c set(pos,false). */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& reset(size_t __position) { @@ -1119,6 +1165,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER /** * @brief Toggles every bit to its opposite value. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& flip() _GLIBCXX_NOEXCEPT { @@ -1132,6 +1179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @param __position The index of the bit. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ + _GLIBCXX23_CONSTEXPR bitset<_Nb>& flip(size_t __position) { @@ -1140,6 +1188,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } /// See the no-argument flip(). + _GLIBCXX23_CONSTEXPR bitset<_Nb> operator~() const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this).flip(); } @@ -1159,6 +1208,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * The DR has since been changed: range-checking is a precondition * (users' responsibility), and these functions must not throw. -pme */ + _GLIBCXX23_CONSTEXPR reference operator[](size_t __position) { return reference(*this, __position); } @@ -1174,16 +1224,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @throw std::overflow_error If there are too many bits to be * represented in an @c unsigned @c long. */ + _GLIBCXX23_CONSTEXPR unsigned long to_ulong() const { return this->_M_do_to_ulong(); } #if __cplusplus >= 201103L + _GLIBCXX23_CONSTEXPR unsigned long long to_ullong() const { return this->_M_do_to_ullong(); } #endif +#if _GLIBCXX_HOSTED /** * @brief Returns a character interpretation of the %bitset. * @return The string equivalent of the bits. @@ -1193,6 +1246,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * an example). */ template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, _Alloc> to_string() const { @@ -1204,6 +1258,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 396. what are characters zero and one. template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, _Alloc> to_string(_CharT __zero, _CharT __one = _CharT('1')) const { @@ -1215,6 +1270,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 434. bitset::to_string() hard to use. template<class _CharT, class _Traits> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string() const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(); } @@ -1222,12 +1278,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // _GLIBCXX_RESOLVE_LIB_DEFECTS // 853. to_string needs updating with zero and one. template<class _CharT, class _Traits> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, _Traits, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const { return to_string<_CharT, _Traits, std::allocator<_CharT> >(__zero, __one); } template<class _CharT> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string() const @@ -1237,6 +1295,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<class _CharT> + _GLIBCXX23_CONSTEXPR std::basic_string<_CharT, std::char_traits<_CharT>, std::allocator<_CharT> > to_string(_CharT __zero, _CharT __one = _CharT('1')) const @@ -1245,6 +1304,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER std::allocator<_CharT> >(__zero, __one); } + _GLIBCXX23_CONSTEXPR std::basic_string<char, std::char_traits<char>, std::allocator<char> > to_string() const { @@ -1252,6 +1312,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER std::allocator<char> >(); } + _GLIBCXX23_CONSTEXPR std::basic_string<char, std::char_traits<char>, std::allocator<char> > to_string(char __zero, char __one = '1') const { @@ -1261,11 +1322,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER // Helper functions for string operations. template<class _CharT, class _Traits> + _GLIBCXX23_CONSTEXPR void _M_copy_from_ptr(const _CharT*, size_t, size_t, size_t, _CharT, _CharT); template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR void _M_copy_from_string(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __pos, size_t __n, @@ -1274,23 +1337,28 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __zero, __one); } template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR void _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>&, _CharT, _CharT) const; // NB: Backward compat. template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR void _M_copy_from_string(const std::basic_string<_CharT, _Traits, _Alloc>& __s, size_t __pos, size_t __n) { _M_copy_from_string(__s, __pos, __n, _CharT('0'), _CharT('1')); } template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR void _M_copy_to_string(std::basic_string<_CharT, _Traits,_Alloc>& __s) const { _M_copy_to_string(__s, _CharT('0'), _CharT('1')); } +#endif // HOSTED /// Returns the number of bits which are set. + _GLIBCXX23_CONSTEXPR size_t count() const _GLIBCXX_NOEXCEPT { return this->_M_do_count(); } @@ -1302,11 +1370,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ///@{ /// These comparisons for equality/inequality are, well, @e bitwise. + _GLIBCXX23_CONSTEXPR bool operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return this->_M_is_equal(__rhs); } #if __cpp_impl_three_way_comparison < 201907L + _GLIBCXX23_CONSTEXPR bool operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT { return !this->_M_is_equal(__rhs); } @@ -1319,6 +1389,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @return The value at @a pos. * @throw std::out_of_range If @a pos is bigger the size of the %set. */ + _GLIBCXX23_CONSTEXPR bool test(size_t __position) const { @@ -1332,6 +1403,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief Tests whether all the bits are on. * @return True if all the bits are set. */ + _GLIBCXX23_CONSTEXPR bool all() const _GLIBCXX_NOEXCEPT { return this->template _M_are_all<_Nb>(); } @@ -1340,6 +1412,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief Tests whether any of the bits are on. * @return True if at least one bit is set. */ + _GLIBCXX23_CONSTEXPR bool any() const _GLIBCXX_NOEXCEPT { return this->_M_is_any(); } @@ -1348,16 +1421,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @brief Tests whether any of the bits are on. * @return True if none of the bits are set. */ + _GLIBCXX23_CONSTEXPR bool none() const _GLIBCXX_NOEXCEPT { return !this->_M_is_any(); } ///@{ /// Self-explanatory. + _GLIBCXX23_CONSTEXPR bitset<_Nb> operator<<(size_t __position) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this) <<= __position; } + _GLIBCXX23_CONSTEXPR bitset<_Nb> operator>>(size_t __position) const _GLIBCXX_NOEXCEPT { return bitset<_Nb>(*this) >>= __position; } @@ -1369,6 +1445,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @ingroup SGIextensions * @sa _Find_next */ + _GLIBCXX23_CONSTEXPR size_t _Find_first() const _GLIBCXX_NOEXCEPT { return this->_M_do_find_first(_Nb); } @@ -1380,14 +1457,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * @ingroup SGIextensions * @sa _Find_first */ + _GLIBCXX23_CONSTEXPR size_t _Find_next(size_t __prev) const _GLIBCXX_NOEXCEPT { return this->_M_do_find_next(__prev, _Nb); } }; +#if _GLIBCXX_HOSTED // Definitions of non-inline member functions. template<size_t _Nb> template<class _CharT, class _Traits> + _GLIBCXX23_CONSTEXPR void bitset<_Nb>:: _M_copy_from_ptr(const _CharT* __s, size_t __len, @@ -1409,16 +1489,21 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template<size_t _Nb> template<class _CharT, class _Traits, class _Alloc> + _GLIBCXX23_CONSTEXPR void bitset<_Nb>:: _M_copy_to_string(std::basic_string<_CharT, _Traits, _Alloc>& __s, _CharT __zero, _CharT __one) const { __s.assign(_Nb, __zero); - for (size_t __i = _Nb; __i > 0; --__i) - if (_Unchecked_test(__i - 1)) - _Traits::assign(__s[_Nb - __i], __one); + size_t __n = this->_Find_first(); + while (__n < _Nb) + { + __s[_Nb - __n - 1] = __one; + __n = _Find_next(__n); + } } +#endif // HOSTED // 23.3.5.3 bitset operations: ///@{ @@ -1431,6 +1516,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * These should be self-explanatory. */ template<size_t _Nb> + _GLIBCXX23_CONSTEXPR inline bitset<_Nb> operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { @@ -1440,6 +1526,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template<size_t _Nb> + _GLIBCXX23_CONSTEXPR inline bitset<_Nb> operator|(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { @@ -1449,6 +1536,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } template <size_t _Nb> + _GLIBCXX23_CONSTEXPR inline bitset<_Nb> operator^(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT { @@ -1458,6 +1546,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } ///@} +#if _GLIBCXX_HOSTED ///@{ /** * @brief Global I/O operators for bitsets. @@ -1527,7 +1616,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (__tmp.empty() && _Nb) __state |= __ios_base::failbit; - else + else if _GLIBCXX17_CONSTEXPR (_Nb) __x._M_copy_from_string(__tmp, static_cast<size_t>(0), _Nb, __zero, __one); if (__state) @@ -1549,6 +1638,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER return __os << __tmp; } ///@} +#endif // HOSTED _GLIBCXX_END_NAMESPACE_CONTAINER } // namespace std @@ -1557,7 +1647,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER #undef _GLIBCXX_BITSET_BITS_PER_WORD #undef _GLIBCXX_BITSET_BITS_PER_ULL -#if __cplusplus >= 201103L +#if __cplusplus >= 201103L && _GLIBCXX_HOSTED namespace std _GLIBCXX_VISIBILITY(default) { @@ -1591,7 +1681,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #endif // C++11 -#ifdef _GLIBCXX_DEBUG +#if defined _GLIBCXX_DEBUG && _GLIBCXX_HOSTED # include <debug/bitset> #endif diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 94e73ea..c5853fc 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1451,12 +1451,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #pragma GCC diagnostic pop - // is_nothrow_convertible for C++11 - template<typename _From, typename _To> - struct __is_nothrow_convertible - : public __is_nt_convertible_helper<_From, _To>::type - { }; - #if __cplusplus > 201703L #define __cpp_lib_is_nothrow_convertible 201806L /// is_nothrow_convertible @@ -2557,13 +2551,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @cond undocumented + // Detection idiom. + // Detect whether _Op<_Args...> is a valid type, use default _Def if not. + +#if __cpp_concepts + // Implementation of the detection idiom (negative case). + template<typename _Def, template<typename...> class _Op, typename... _Args> + struct __detected_or + { + using type = _Def; + using __is_detected = false_type; + }; + + // Implementation of the detection idiom (positive case). + template<typename _Def, template<typename...> class _Op, typename... _Args> + requires requires { typename _Op<_Args...>; } + struct __detected_or<_Def, _Op, _Args...> + { + using type = _Op<_Args...>; + using __is_detected = true_type; + }; +#else /// Implementation of the detection idiom (negative case). template<typename _Default, typename _AlwaysVoid, template<typename...> class _Op, typename... _Args> struct __detector { - using value_t = false_type; using type = _Default; + using __is_detected = false_type; }; /// Implementation of the detection idiom (positive case). @@ -2571,14 +2586,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typename... _Args> struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...> { - using value_t = true_type; using type = _Op<_Args...>; + using __is_detected = true_type; }; - // Detect whether _Op<_Args...> is a valid type, use _Default if not. template<typename _Default, template<typename...> class _Op, typename... _Args> using __detected_or = __detector<_Default, void, _Op, _Args...>; +#endif // __cpp_concepts // _Op<_Args...> if that is a valid type, otherwise _Default. template<typename _Default, template<typename...> class _Op, @@ -2825,7 +2840,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // The primary template is used for invalid INVOKE expressions. template<typename _Result, typename _Ret, bool = is_void<_Ret>::value, typename = void> - struct __is_invocable_impl : false_type { }; + struct __is_invocable_impl + : false_type + { + using __nothrow_type = false_type; // For is_nothrow_invocable_r + }; // Used for valid INVOKE and INVOKE<void> expressions. template<typename _Result, typename _Ret> @@ -2833,7 +2852,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /* is_void<_Ret> = */ true, __void_t<typename _Result::type>> : true_type - { }; + { + using __nothrow_type = true_type; // For is_nothrow_invocable_r + }; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wctor-dtor-privacy" @@ -2845,23 +2866,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { private: // The type of the INVOKE expression. - // Unlike declval, this doesn't add_rvalue_reference. - static typename _Result::type _S_get(); + // Unlike declval, this doesn't add_rvalue_reference, so it respects + // guaranteed copy elision. + static typename _Result::type _S_get() noexcept; template<typename _Tp> - static void _S_conv(_Tp); + static void _S_conv(_Tp) noexcept; // This overload is viable if INVOKE(f, args...) can convert to _Tp. - template<typename _Tp, typename = decltype(_S_conv<_Tp>(_S_get()))> - static true_type + template<typename _Tp, bool _Check_Noex = false, + typename = decltype(_S_conv<_Tp>(_S_get())), + bool _Noex = noexcept(_S_conv<_Tp>(_S_get()))> + static __bool_constant<_Check_Noex ? _Noex : true> _S_test(int); - template<typename _Tp> + template<typename _Tp, bool = false> static false_type _S_test(...); public: + // For is_invocable_r using type = decltype(_S_test<_Ret>(1)); + + // For is_nothrow_invocable_r + using __nothrow_type = decltype(_S_test<_Ret, true>(1)); }; #pragma GCC diagnostic pop @@ -2992,15 +3020,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// @cond undocumented - template<typename _Result, typename _Ret, typename = void> - struct __is_nt_invocable_impl : false_type { }; - template<typename _Result, typename _Ret> - struct __is_nt_invocable_impl<_Result, _Ret, - __void_t<typename _Result::type>> - : __or_<is_void<_Ret>, - __is_nothrow_convertible<typename _Result::type, _Ret>>::type - { }; + using __is_nt_invocable_impl + = typename __is_invocable_impl<_Result, _Ret>::__nothrow_type; /// @endcond /// std::is_nothrow_invocable_r diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 6b61879..3fd5182 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -309,6 +309,7 @@ #if _GLIBCXX_HOSTED #define __cpp_lib_adaptor_iterator_pair_constructor 202106L #if __cpp_constexpr_dynamic_alloc +# define __cpp_lib_constexpr_bitset 202202L # undef __cpp_lib_constexpr_memory # define __cpp_lib_constexpr_memory 202202L #endif diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index bd4289c..5a3dcbd 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -2246,12 +2246,7 @@ def build_libstdcxx_dictionary (): libstdcxx_printer.add('std::__debug::map', StdMapPrinter) libstdcxx_printer.add('std::__debug::multimap', StdMapPrinter) libstdcxx_printer.add('std::__debug::multiset', StdSetPrinter) - libstdcxx_printer.add('std::__debug::priority_queue', - StdStackOrQueuePrinter) - libstdcxx_printer.add('std::__debug::queue', StdStackOrQueuePrinter) libstdcxx_printer.add('std::__debug::set', StdSetPrinter) - libstdcxx_printer.add('std::__debug::stack', StdStackOrQueuePrinter) - libstdcxx_printer.add('std::__debug::unique_ptr', UniquePointerPrinter) libstdcxx_printer.add('std::__debug::vector', StdVectorPrinter) # These are the TR1 and C++11 printers. diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc index 20cda77..b8b3747 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++1998/all_attributes.cc @@ -38,8 +38,3 @@ #include <bits/extc++.h> #include <cxxabi.h> - -int -main() -{ -} diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc index c2b4c23..222ab78 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/all_attributes.cc @@ -38,8 +38,3 @@ #include <bits/extc++.h> #include <cxxabi.h> - -int -main() -{ -} diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc index f6c4251..b31d13f 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++2014/all_attributes.cc @@ -38,8 +38,3 @@ #include <bits/extc++.h> #include <cxxabi.h> - -int -main() -{ -} diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc index 170ebef..fd4d7d4 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++2017/all_attributes.cc @@ -37,8 +37,3 @@ #include <bits/extc++.h> #include <cxxabi.h> - -int -main() -{ -} diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc index 1d573a2..f700bad 100644 --- a/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc +++ b/libstdc++-v3/testsuite/17_intro/headers/c++2020/all_attributes.cc @@ -36,8 +36,3 @@ #include <bits/extc++.h> #include <cxxabi.h> - -int -main() -{ -} diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index 82e201c..6490cd6 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -112,6 +112,7 @@ #define tmp ( #define sz ( #define token ( +#define value_t ( #if __cplusplus < 201103L #define uses_allocator ( diff --git a/libstdc++-v3/testsuite/18_support/uncaught_exception/14026.cc b/libstdc++-v3/testsuite/18_support/uncaught_exception/14026.cc index 22d4a90..bd281b9 100644 --- a/libstdc++-v3/testsuite/18_support/uncaught_exception/14026.cc +++ b/libstdc++-v3/testsuite/18_support/uncaught_exception/14026.cc @@ -28,7 +28,7 @@ static void no_uncaught () { if (std::uncaught_exception()) - abort(); + std::abort(); } int diff --git a/libstdc++-v3/testsuite/20_util/bitset/107037.cc b/libstdc++-v3/testsuite/20_util/bitset/107037.cc new file mode 100644 index 0000000..b4560dd --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/107037.cc @@ -0,0 +1,7 @@ +// { dg-options "-std=c++03" } +// { dg-do compile } +// PR libstdc++/107037 bitset::_M_do_reset fails for strict -std=c++03 mode +#include <bitset> +template class std::bitset<0>; +template class std::bitset<1>; +template class std::bitset<100>; diff --git a/libstdc++-v3/testsuite/23_containers/bitset/18604.cc b/libstdc++-v3/testsuite/20_util/bitset/18604.cc index f91cdfa..f91cdfa 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/18604.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/18604.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/45713.cc b/libstdc++-v3/testsuite/20_util/bitset/45713.cc index 5cec1b5..5cec1b5 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/45713.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/45713.cc diff --git a/libstdc++-v3/testsuite/20_util/bitset/access/constexpr.cc b/libstdc++-v3/testsuite/20_util/bitset/access/constexpr.cc new file mode 100644 index 0000000..53bb07f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/access/constexpr.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <bitset> +#include <string> +#include <testsuite_hooks.h> + +constexpr bool +test_indexing() +{ + std::bitset<100> b("10010110"); + VERIFY( b[0] == 0 ); + VERIFY( b[1] == 1 ); + const auto& cb = b; + VERIFY( cb[0] == 0 ); + VERIFY( cb[1] == 1 ); + b[1].flip(); + VERIFY( cb[1] == 0 ); + VERIFY( b[1] == 0 ); + VERIFY( ~b[1] == 1 ); + b[3] = true; + bool b3 = b[3]; + VERIFY( b3 ); + b[4] = b[3]; + return true; +} + +static_assert( test_indexing() ); + +#if _GLIBCXX_USE_CXX11_ABI +constexpr bool +test_to_string() +{ + std::string str = "01101001"; + return std::bitset<8>(str).to_string() == str; +} + +static_assert( test_to_string() ); +#endif + +constexpr bool +test_to_ulong() +{ + unsigned long val = 0xcabba123; + return std::bitset<100>(val).to_ulong() == val; +} + +static_assert( test_to_ulong() ); + +constexpr bool +test_to_ullong() +{ + unsigned long long val = 0x0123abcd0123abcd; + return std::bitset<100>(val).to_ullong() == val; +} + +static_assert( test_to_ullong() ); diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_string/dr396.cc b/libstdc++-v3/testsuite/20_util/bitset/access/dr396.cc index dfba27e..dfba27e 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/to_string/dr396.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/access/dr396.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc b/libstdc++-v3/testsuite/20_util/bitset/access/to_string.cc index 8384eb9..8384eb9 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/to_string/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/access/to_string.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc b/libstdc++-v3/testsuite/20_util/bitset/access/to_ullong.cc index 18fc077..18fc077 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/to_ullong/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/access/to_ullong.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc b/libstdc++-v3/testsuite/20_util/bitset/access/to_ulong.cc index 8163701..8163701 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/to_ulong/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/access/to_ulong.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/1.cc index c2a54c3..c2a54c3 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/16020.cc index ffccdd2..ffccdd2 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/16020.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/16020.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/2.cc index 947124e..947124e 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/2.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/2.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/3.cc index 6308e4e..6308e4e 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/3.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/3.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/38244.cc index 610197c..610197c 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/38244.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/38244.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/50268.cc index 6d4b946..6d4b946 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/50268.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/50268.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/6282.cc index 5409336..5409336 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/6282.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/6282.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/constexpr.cc index bf16b19..bf16b19 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/constexpr.cc diff --git a/libstdc++-v3/testsuite/20_util/bitset/cons/constexpr_c++23.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/constexpr_c++23.cc new file mode 100644 index 0000000..532fc9d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/constexpr_c++23.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <bitset> + +#ifndef __cpp_lib_constexpr_bitset +# error "Feature-test macro for constexpr bitset missing in <bitset>" +#elif __cpp_lib_constexpr_bitset != 202202L +# error "Feature-test macro for constexpr bitset has wrong value in <bitset>" +#endif + +#include <testsuite_hooks.h> + +constexpr bool test_ntbs() +{ + VERIFY( std::bitset<0>("000").all() ); + VERIFY( std::bitset<0>("000", 2).all() ); + VERIFY( std::bitset<1>("100", 2).all() ); + VERIFY( std::bitset<1>("z00", 2, 'z').none() ); + VERIFY( std::bitset<2>("ab0", 3, 'a', 'b').count() == 1 ); + + return true; +} + +static_assert( test_ntbs() ); + +#if _GLIBCXX_USE_CXX11_ABI +constexpr bool test_string() +{ + using S = std::string; + VERIFY( std::bitset<0>(S("000")).all() ); + VERIFY( std::bitset<1>(S("010"), 1, 2).all() ); + VERIFY( std::bitset<2>(S("0110"), 1, 2).all() ); + VERIFY( std::bitset<2>(S("1z110"), 1, 3, 'z').count() == 1 ); + VERIFY( std::bitset<3>(S("0abab0"), 2, 3, 'a', 'b').count() == 2 ); + + return true; +} + +static_assert( test_string() ); + +constexpr bool test_wstring() +{ + using S = std::wstring; + VERIFY( std::bitset<0>(S(L"000")).all() ); + VERIFY( std::bitset<1>(S(L"010"), 1, 2).all() ); + VERIFY( std::bitset<2>(S(L"0110"), 1, 2).all() ); + VERIFY( std::bitset<2>(S(L"1z110"), 1, 3, L'z').count() == 1 ); + VERIFY( std::bitset<3>(S(L"0abab0"), 2, 3, L'a', L'b').count() == 2 ); + + return true; +} + +static_assert( test_wstring() ); +#endif diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/dr1325-1.cc index aa50804..aa50804 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/dr1325-1.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/dr1325-2.cc index 2371bef..2371bef 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr1325-2.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/dr1325-2.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc b/libstdc++-v3/testsuite/20_util/bitset/cons/dr396.cc index f1f9d87..f1f9d87 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/cons/dr396.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/cons/dr396.cc diff --git a/libstdc++-v3/testsuite/20_util/bitset/count/constexpr.cc b/libstdc++-v3/testsuite/20_util/bitset/count/constexpr.cc new file mode 100644 index 0000000..98f8e22 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/count/constexpr.cc @@ -0,0 +1,93 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <bitset> +#include <testsuite_hooks.h> + +constexpr bool +test_counting() +{ + auto check = []<std::size_t N>(const std::bitset<N>& bs) { + VERIFY( bs.size() == N ); + unsigned count = 0; + for (unsigned n = 0; n < N; ++n) + if (bs.test(n)) + ++count; + VERIFY( count == bs.count() ); + VERIFY( bs.all() == (bs.count() == bs.size()) ); + VERIFY( bs.any() == (bs.count() != 0) ); + VERIFY( bs.none() == (bs.count() == 0) ); + return true; + }; + + std::bitset<0> z0; + VERIFY( z0.count() == 0 ); + VERIFY( check(z0) ); + z0.set(); + VERIFY( z0.count() == 0 ); + VERIFY( check(z0) ); + + std::bitset<7> z7; + VERIFY( z7.count() == 0 ); + VERIFY( check(z7) ); + z7.set(); + VERIFY( z7.count() == 7 ); + VERIFY( check(z7) ); + z7.flip(1); + VERIFY( z7.count() == 6 ); + VERIFY( check(z7) ); + + std::bitset<31> z31; + VERIFY( z31.count() == 0 ); + VERIFY( check(z31) ); + z31.set(); + VERIFY( z31.count() == 31 ); + VERIFY( check(z31) ); + z31.flip(1); + VERIFY( z31.count() == 30 ); + VERIFY( check(z31) ); + + std::bitset<32> z32; + VERIFY( z32.count() == 0 ); + VERIFY( check(z32) ); + z32.set(); + VERIFY( z32.count() == 32 ); + VERIFY( check(z32) ); + z32.flip(1); + VERIFY( z32.count() == 31 ); + VERIFY( check(z32) ); + + std::bitset<63> z63; + VERIFY( z63.count() == 0 ); + VERIFY( check(z63) ); + z63.set(); + VERIFY( z63.count() == 63 ); + VERIFY( check(z63) ); + z63.flip(1); + VERIFY( z63.count() == 62 ); + VERIFY( check(z63) ); + + std::bitset<64> z64; + VERIFY( z64.count() == 0 ); + VERIFY( check(z64) ); + z64.set(); + VERIFY( z64.count() == 64 ); + VERIFY( check(z64) ); + z64.flip(1); + VERIFY( z64.count() == 63 ); + VERIFY( check(z64) ); + + std::bitset<1000> z1k; + VERIFY( z1k.count() == 0 ); + VERIFY( check(z1k) ); + z1k.set(); + VERIFY( z1k.count() == 1000 ); + VERIFY( check(z1k) ); + z1k.flip(1); + VERIFY( z1k.count() == 999 ); + VERIFY( check(z1k) ); + + return true; +} + +static_assert( test_counting() ); diff --git a/libstdc++-v3/testsuite/23_containers/bitset/debug/invalidation/1.cc b/libstdc++-v3/testsuite/20_util/bitset/debug/invalidation/1.cc index 5d0e3c15..5d0e3c15 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/debug/invalidation/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/debug/invalidation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc b/libstdc++-v3/testsuite/20_util/bitset/ext/15361.cc index 3924700..3924700 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/ext/15361.cc diff --git a/libstdc++-v3/testsuite/20_util/bitset/ext/constexpr.cc b/libstdc++-v3/testsuite/20_util/bitset/ext/constexpr.cc new file mode 100644 index 0000000..f82e7aa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/ext/constexpr.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <bitset> +#include <testsuite_hooks.h> + +constexpr bool +test_find() +{ + VERIFY( std::bitset<0>()._Find_first() == 0 ); + VERIFY( std::bitset<1>()._Find_first() == 1 ); + VERIFY( std::bitset<55>("001000")._Find_first() == 3 ); + VERIFY( std::bitset<66>("101000")._Find_next(3) == 5 ); + return true; +} + +static_assert( test_find() ); + +constexpr bool +test_unchecked() +{ + VERIFY( std::bitset<1>()._Unchecked_set(0).count() == 1 ); + VERIFY( std::bitset<44>()._Unchecked_set(3).count() == 1 ); + VERIFY( std::bitset<55>()._Unchecked_set(3, 0).count() == 0 ); + VERIFY( std::bitset<66>()._Unchecked_set(3, 1).count() == 1 ); + VERIFY( std::bitset<77>("111")._Unchecked_reset(1).count() == 2 ); + VERIFY( std::bitset<88>("101")._Unchecked_flip(1).count() == 3 ); + VERIFY( std::bitset<99>("010")._Unchecked_test(1) ); + return true; +} + +static_assert( test_unchecked() ); diff --git a/libstdc++-v3/testsuite/23_containers/bitset/hash/1.cc b/libstdc++-v3/testsuite/20_util/bitset/hash/1.cc index aba6b72..aba6b72 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/hash/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/hash/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/input/1.cc b/libstdc++-v3/testsuite/20_util/bitset/io/input.cc index 939861b..0f22cef 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/input/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/io/input.cc @@ -39,7 +39,7 @@ void test01() ss.clear(); ss.str("*"); ss >> b0; - VERIFY( ss.rdstate() == ios_base::goodbit ); + VERIFY( ss.rdstate() == ios_base::goodbit ); // LWG 3199 } int main() diff --git a/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc b/libstdc++-v3/testsuite/20_util/bitset/observers/6124.cc index d08211c..d08211c 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/count/6124.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/observers/6124.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc b/libstdc++-v3/testsuite/20_util/bitset/observers/all.cc index 9840f25..9840f25 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/all/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/observers/all.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc b/libstdc++-v3/testsuite/20_util/bitset/observers/test.cc index 2444499..2444499 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/test/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/observers/test.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/1.cc index 5894210..5894210 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/13838.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/13838.cc index c38ccc3..c38ccc3 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/13838.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/13838.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/2.cc index a909e38..a909e38 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/2.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/2.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/96303.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/96303.cc index b1f729d..b1f729d 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/96303.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/96303.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr-2.cc index 91098d9..91098d9 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr-2.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr-2.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr.cc index 3f77003..3f77003 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/operations/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr.cc diff --git a/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr_c++23.cc b/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr_c++23.cc new file mode 100644 index 0000000..c594dd6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/operations/constexpr_c++23.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++23" } +// { dg-do compile { target c++23 } } + +#include <bitset> +#include <testsuite_hooks.h> + +constexpr bool +test() +{ + std::bitset<16> b0; + std::bitset<16> b1 = ~b0; + VERIFY( b1.all() ); + b0 &= b1; + VERIFY( b0.none() ); + b0 |= b1; + VERIFY( b0.all() ); + b0 ^= b1; + VERIFY( b0.none() ); + b0 = b1 << 8; + VERIFY( !b0.all() && !b0.none() ); + VERIFY( ((b1 << 8) | (b1 >> 8)).all() ); + b1 <<= 8; + b1 >>= 8; + b1 >>= 8; + VERIFY( b1.none() ); + VERIFY( (~b1).all() ); + VERIFY( b1.flip().all() ); + return true; +} + +static_assert( test() ); diff --git a/libstdc++-v3/testsuite/23_containers/bitset/requirements/constexpr_functions.cc b/libstdc++-v3/testsuite/20_util/bitset/requirements/constexpr_functions.cc index a3c9047..a3c9047 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/requirements/constexpr_functions.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/requirements/constexpr_functions.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/bitset/requirements/explicit_instantiation/1.cc index d1d8f57..d1d8f57 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/requirements/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc b/libstdc++-v3/testsuite/20_util/bitset/requirements/explicit_instantiation/1_c++0x.cc index 9a1c147..9a1c147 100644 --- a/libstdc++-v3/testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc +++ b/libstdc++-v3/testsuite/20_util/bitset/requirements/explicit_instantiation/1_c++0x.cc diff --git a/libstdc++-v3/testsuite/20_util/bitset/version.cc b/libstdc++-v3/testsuite/20_util/bitset/version.cc new file mode 100644 index 0000000..7197b1e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/bitset/version.cc @@ -0,0 +1,10 @@ +// { dg-options "-std=gnu++23" } +// { dg-do preprocess { target c++23 } } + +#include <version> + +#ifndef __cpp_lib_constexpr_bitset +# error "Feature-test macro for constexpr bitset missing in <version>" +#elif __cpp_lib_constexpr_bitset != 202202L +# error "Feature-test macro for constexpr bitset has wrong value in <version>" +#endif diff --git a/libstdc++-v3/testsuite/20_util/function/91456.cc b/libstdc++-v3/testsuite/20_util/function/91456.cc index 6b6631c..081bf20 100644 --- a/libstdc++-v3/testsuite/20_util/function/91456.cc +++ b/libstdc++-v3/testsuite/20_util/function/91456.cc @@ -17,6 +17,9 @@ // { dg-do compile { target c++17 } } +// PR 91456 +// std::function and std::is_invocable_r do not understand guaranteed elision + #include <functional> struct Immovable { diff --git a/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/bitset/synopsis.cc index e7ea4f8..ed5604b 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc +++ b/libstdc++-v3/testsuite/20_util/headers/bitset/synopsis.cc @@ -27,17 +27,26 @@ # define NOTHROW #endif +#if __cplusplus > 202002L +# define CONSTEXPR constexpr +#else +# define CONSTEXPR +#endif + namespace std { template <size_t N> class bitset; // 23.3.5.3 bitset operations: template <size_t N> + CONSTEXPR bitset<N> operator&(const bitset<N>&, const bitset<N>&) NOTHROW; template <size_t N> + CONSTEXPR bitset<N> operator|(const bitset<N>&, const bitset<N>&) NOTHROW; template <size_t N> + CONSTEXPR bitset<N> operator^(const bitset<N>&, const bitset<N>&) NOTHROW; template <class charT, class traits, size_t N> diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc index 03e3f80d..15437c7 100644 --- a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc +++ b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -26,20 +26,35 @@ # define NOTHROW #endif -namespace std { +namespace std +{ +#if __cplusplus >= 201103L + template<class Ptr> struct pointer_traits; + template<class T> struct pointer_traits<T*>; + + void* align(size_t alignment, size_t size, void*& ptr, size_t& space); + + struct allocator_arg_t; + extern const allocator_arg_t allocator_arg; + + template<class T, class Alloc> struct uses_allocator; + + template<class Alloc> struct allocator_traits; +#endif // C++11 + +#if __STDC_HOSTED__ // lib.default.allocator, the default allocator: template <class T> class allocator; +#if __cplusplus >= 202002L + template <class T, class U> + constexpr bool operator==(const allocator<T>&, const allocator<U>&) throw(); +#else template <> class allocator<void>; template <class T, class U> -#if __cplusplus > 201703L - constexpr -#endif bool operator==(const allocator<T>&, const allocator<U>&) throw(); template <class T, class U> -#if __cplusplus > 201703L - constexpr -#endif bool operator!=(const allocator<T>&, const allocator<U>&) throw(); +#endif // lib.storage.iterator, raw storage iterator: template <class OutputIterator, class T> class raw_storage_iterator; @@ -49,18 +64,55 @@ namespace std { pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) NOTHROW; template <class T> void return_temporary_buffer(T* p); +#endif // HOSTED // lib.specialized.algorithms, specialized algorithms: +#if __cplusplus >= 201703L + template <class T> constexpr T* addressof(T&) noexcept; +#elif __cplusplus >= 201402L + template <class T> T* addressof(T&) noexcept; +#endif template <class InputIterator, class ForwardIterator> ForwardIterator uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); +#if __cplusplus >= 201103L + template <class InputIterator, class Size, class ForwardIterator> + ForwardIterator + uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); +#endif template <class ForwardIterator, class T> void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); template <class ForwardIterator, class Size, class T> void uninitialized_fill_n(ForwardIterator first, Size n, const T& x); +#if __cplusplus >= 201103L + template<class T> class default_delete; + template<class T> class default_delete<T[]>; + template<class T, class D> class unique_ptr; + template<class T, class D> class unique_ptr<T[], D>; + template<class T, class D> + void swap(unique_ptr<T, D>&, unique_ptr<T, D>&) noexcept; +#if __cplusplus >= 201402L + template<class T, class... Args> unique_ptr<T> make_unique(Args&&...); +#endif + + class bad_weak_ptr; + template<class T> class shared_ptr; + template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args); + template<class T, class A, class... Args> + shared_ptr<T> allocate_shared(const A& a, Args&&... args); + template<class T> void swap(shared_ptr<T>&, shared_ptr<T>&) noexcept; + template<class T> class weak_ptr; + template<class T> void swap(weak_ptr<T>&, weak_ptr<T>&) noexcept; + template<class T> class owner_less; + template<class T> class enable_shared_from_this; + + template<class T, class D> struct hash<unique_ptr<T, D>>; + template<class T> struct hash<shared_ptr<T>>; +#endif + // lib.auto.ptr, pointers: template<class X> class auto_ptr; } diff --git a/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc b/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc new file mode 100644 index 0000000..a96fba6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_assignable/requirements/access.cc @@ -0,0 +1,22 @@ +// { dg-do compile { target c++11 } } + +#include <type_traits> + +class S { + operator int(); + friend void g(); // #1 +}; + +void +g() +{ + int i = 0; + S s; + i = s; // this works, because we're inside a friend. + + // But the traits are evaluated in "a context unrelated to either type". + static_assert( ! std::is_assignable<int&, S>::value, "unfriendly"); +#if __cplusplus >= 201703L + static_assert( ! std::is_assignable_v<int&, S>, "unfriendly"); +#endif +} diff --git a/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc b/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc index a946db1..976d257 100644 --- a/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc +++ b/libstdc++-v3/testsuite/20_util/is_invocable/91456.cc @@ -17,6 +17,9 @@ // { dg-do compile { target c++17 } } +// PR 91456 +// std::function and std::is_invocable_r do not understand guaranteed elision + #include <type_traits> #include <functional> @@ -27,7 +30,6 @@ struct Immovable { Immovable& operator=(const Immovable&) = delete; }; -Immovable get() { return {}; } -const Immovable i = get(); // OK -std::function<const Immovable()> f{&get}; // fails -const Immovable i2 = f(); +static_assert(std::is_invocable_r_v<Immovable, Immovable(*)()>); +static_assert(std::is_invocable_r_v<const Immovable, Immovable(*)()>); +static_assert(std::is_invocable_r_v<Immovable, const Immovable(*)()>); diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value.cc index e9aded7..a268628 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value.cc @@ -21,9 +21,7 @@ #include <type_traits> #include <testsuite_tr1.h> -#ifndef IS_NT_CONVERTIBLE_DEFINED using std::is_nothrow_convertible; -#endif void test01() { diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value_ext.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/91456.cc index 0f89642..abbbd1a 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_convertible/value_ext.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_invocable/91456.cc @@ -15,14 +15,21 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-do compile { target c++11 } } +// { dg-do compile { target c++17 } } + +// PR 91456 +// std::function and std::is_invocable_r do not understand guaranteed elision #include <type_traits> -// Test the non-standard __is_nothrow_convertible trait +#include <functional> -template<typename From, typename To> - using is_nothrow_convertible = std::__is_nothrow_convertible<From, To>; +struct Immovable { + Immovable() = default; + Immovable(const Immovable&) = delete; + Immovable& operator=(const Immovable&) = delete; +}; -#define IS_NT_CONVERTIBLE_DEFINED -#include "value.cc" +static_assert(std::is_nothrow_invocable_r_v<Immovable, Immovable(*)() noexcept>); +static_assert(std::is_nothrow_invocable_r_v<const Immovable, Immovable(*)() noexcept>); +static_assert(std::is_nothrow_invocable_r_v<Immovable, const Immovable(*)() noexcept>); |