From 0598e2f98d28f3ddbf1a4bbced8177ea6b58ad93 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Mon, 25 Nov 2024 15:06:13 +0000 Subject: [PATCH] libstdc++: Improve test for synopsis libstdc++-v3/ChangeLog: * testsuite/20_util/headers/utility/synopsis.cc: Add declarations from C++11 and later. --- .../20_util/headers/utility/synopsis.cc | 108 +++++++++++++++++- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc index dddb54fd48a..51e88b70f51 100644 --- a/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc +++ b/libstdc++-v3/testsuite/20_util/headers/utility/synopsis.cc @@ -20,6 +20,36 @@ #include +#if __cplusplus < 201103L +# define CONSTEXPR +#else +# define CONSTEXPR constexpr +#endif + +#if __cplusplus < 201402L && ! defined(_GLIBCXX_RELEASE) +# define CONSTEXPR11x +#else +# define CONSTEXPR11x constexpr +#endif + +#if __cplusplus < 201402L +# define CONSTEXPR14 +#else +# define CONSTEXPR14 constexpr +#endif + +#if __cplusplus < 201703L +# define CONSTEXPR17 +#else +# define CONSTEXPR17 constexpr +#endif + +#if __cplusplus < 202002L +# define CONSTEXPR20 +#else +# define CONSTEXPR20 constexpr +#endif + namespace std { // lib.operators, operators: namespace rel_ops { @@ -29,18 +59,84 @@ namespace std { template bool operator>=(const T&, const T&); } +#if __cplusplus >= 201103L +#if 0 + // N.B. our std::swap doesn't actually match this due to constraints on + // the template parameter. + template + CONSTEXPR20 + void swap(T&, T&) noexcept(is_nothrow_move_constructible::value + && is_nothrow_move_assignable::value); +#endif + + template + CONSTEXPR20 + void swap(T (&a)[N], T (&b)[N]) noexcept(noexcept(swap(*a, *b))); + +#if __cplusplus >= 201703L + template + CONSTEXPR20 + T exchange(T& obj, U&& new_val) +#if defined _GLIBCXX_RELEASE // This noexcept is a libstdc++ extension. + noexcept(__and_, + is_nothrow_assignable>::value) +#endif + ; +#endif + + template + CONSTEXPR11x + T&& forward(typename remove_reference::type& t) noexcept; + template + CONSTEXPR11x + T&& forward(typename remove_reference::type&& t) noexcept; + + template + CONSTEXPR11x + typename remove_reference::type&& move(T&& t) noexcept; + + template + CONSTEXPR17 + typename conditional< ! is_nothrow_move_constructible::value + && is_copy_constructible::value, + const T&, T&&>::type + move_if_noexcept(T& x) noexcept; + +#if __cplusplus >= 201703L + template + constexpr add_const_t& as_const(T& t) noexcept; +#endif + + template + typename add_rvalue_reference::type declval() noexcept; + +#if __cplusplus >= 201402L + template struct integer_sequence; +#endif + +#endif // C++11 + // lib.pairs, pairs: template struct pair; template - _GLIBCXX_CONSTEXPR bool operator==(const pair&, const pair&); + CONSTEXPR bool operator==(const pair&, const pair&); template - _GLIBCXX_CONSTEXPR bool operator< (const pair&, const pair&); + CONSTEXPR bool operator< (const pair&, const pair&); template - _GLIBCXX_CONSTEXPR bool operator!=(const pair&, const pair&); + CONSTEXPR bool operator!=(const pair&, const pair&); template - _GLIBCXX_CONSTEXPR bool operator> (const pair&, const pair&); + CONSTEXPR bool operator> (const pair&, const pair&); template - _GLIBCXX_CONSTEXPR bool operator>=(const pair&, const pair&); + CONSTEXPR bool operator>=(const pair&, const pair&); template - _GLIBCXX_CONSTEXPR bool operator<=(const pair&, const pair&); + CONSTEXPR bool operator<=(const pair&, const pair&); + +#if __cplusplus >= 201103L + struct piecewise_construct_t; +#if __cplusplus >= 201703L + struct in_place_t; + template struct in_place_type_t; + template struct in_place_index_t; +#endif +#endif }