aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/std')
-rw-r--r--libstdc++-v3/include/std/atomic9
-rw-r--r--libstdc++-v3/include/std/functional99
-rw-r--r--libstdc++-v3/include/std/ranges10
-rw-r--r--libstdc++-v3/include/std/type_traits47
4 files changed, 131 insertions, 34 deletions
diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic
index ccb77fa..0a510d8 100644
--- a/libstdc++-v3/include/std/atomic
+++ b/libstdc++-v3/include/std/atomic
@@ -406,21 +406,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
{
- std::__atomic_wait_address_v(&_M_i, __old,
- [__m, this] { return this->load(__m); });
+ std::__atomic_wait_address_v(std::addressof(_M_i), __old,
+ [__m, this] { return this->load(__m); });
}
// TODO add const volatile overload
void
notify_one() noexcept
- { std::__atomic_notify_address(&_M_i, false); }
+ { std::__atomic_notify_address(std::addressof(_M_i), false); }
void
notify_all() noexcept
- { std::__atomic_notify_address(&_M_i, true); }
+ { std::__atomic_notify_address(std::addressof(_M_i), true); }
#endif // __cpp_lib_atomic_wait
-
};
/// Partial specialization for pointer types.
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 1928a27..570e9e9 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -64,6 +64,7 @@
#define __glibcxx_want_not_fn
#define __glibcxx_want_ranges
#define __glibcxx_want_reference_wrapper
+#define __glibcxx_want_common_reference_wrapper
#define __glibcxx_want_transparent_operators
#include <bits/version.h>
@@ -495,6 +496,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
# define _GLIBCXX_DEPR_BIND
#endif
+#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
+ // Return a _Up that has the same cv-quals as _Tp.
+ template<typename _Tp, typename _Up> // _Up should be cv-unqualified
+ struct __cv_like
+ { using type = _Up; };
+
+ template<typename _Tp, typename _Up>
+ struct __cv_like<const _Tp, _Up>
+ { using type = const _Up; };
+
+ template<typename _Tp, typename _Up>
+ struct __cv_like<volatile _Tp, _Up>
+ { using type = volatile _Up; };
+
+ template<typename _Tp, typename _Up>
+ struct __cv_like<const volatile _Tp, _Up>
+ { using type = const volatile _Up; };
+
+ template<typename _Tp, typename _Up>
+ using __cv_like_t = typename __cv_like<_Tp, _Up>::type;
+#endif
+
/// Type of the function object returned from bind().
template<typename _Signature>
class _Bind;
@@ -564,6 +587,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using _Res_type_impl
= __invoke_result_t<_Fn&, _Mu_type<_BArgs, _CallArgs>&&...>;
+#if !_GLIBCXX_EXPLICIT_THIS_PARAMETER
template<typename _CallArgs>
using _Res_type = _Res_type_impl<_Functor, _CallArgs, _Bound_args...>;
@@ -576,6 +600,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename __cv_quals<__dependent<_CallArgs>>::type,
_CallArgs,
typename __cv_quals<_Bound_args>::type...>;
+#endif
public:
template<typename... _Args>
@@ -593,6 +618,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Bind(const _Bind&) = default;
_Bind(_Bind&&) = default;
+#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
+# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this
+ template<typename... _Args,
+ typename _Self,
+ typename _Self_nonref = typename remove_reference<_Self>::type,
+ __enable_if_t<!is_volatile<_Self_nonref>::value, int> = 0,
+ typename _Result
+ = _Res_type_impl<__cv_like_t<_Self_nonref, _Functor>,
+ tuple<_Args...>,
+ __cv_like_t<_Self_nonref, _Bound_args>...>>
+ _GLIBCXX20_CONSTEXPR
+ _Result
+ operator()(this _Self&& __self, _Args&&... __args)
+ {
+ using _Bind_ref = __cv_like_t<_Self_nonref, _Bind>&;
+ if constexpr (is_const<_Self_nonref>::value)
+ return _Bind_ref(__self)
+ .template __call_c<_Result>(std::forward_as_tuple
+ (std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ else
+ return _Bind_ref(__self)
+ .template __call<_Result>(std::forward_as_tuple
+ (std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+
+# if defined(_GLIBCXX_VOLATILE_BIND)
+ template<typename... _Args,
+ typename _Self,
+ typename _Self_nonref = typename remove_reference<_Self>::type,
+ __enable_if_t<is_volatile<_Self_nonref>::value, int> = 0,
+ typename _Result
+ = _Res_type_impl<__cv_like_t<_Self_nonref, _Functor>,
+ tuple<_Args...>,
+ __cv_like_t<_Self_nonref, _Bound_args>...>>
+ _GLIBCXX_DEPR_BIND
+ _Result
+ operator()(this _Self&& __self, _Args&&... __args)
+ {
+ using _Bind_ref = __cv_like_t<_Self_nonref, _Bind>&;
+ if constexpr (is_const<_Self_nonref>::value)
+ return _Bind_ref(__self)
+ .template __call_c_v<_Result>(std::forward_as_tuple
+ (std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ else
+ return _Bind_ref(__self)
+ .template __call_v<_Result>(std::forward_as_tuple
+ (std::forward<_Args>(__args)...),
+ _Bound_indexes());
+ }
+# endif
+# pragma GCC diagnostic pop
+#else
// Call unqualified
template<typename... _Args,
typename _Result = _Res_type<tuple<_Args...>>>
@@ -642,6 +724,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Bound_indexes());
}
#endif // volatile
+#endif
};
/// Type of the function object returned from bind<R>().
@@ -1056,6 +1139,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Not_fn(_Not_fn&& __fn) = default;
~_Not_fn() = default;
+#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this
+ template<typename _Self, typename... _Args>
+ _GLIBCXX20_CONSTEXPR
+ decltype(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>())
+ operator()(this _Self&& __self, _Args&&... __args)
+ noexcept(__is_nothrow_invocable<__like_t<_Self, _Fn>, _Args...>::value
+ && noexcept(_S_not<__inv_res_t<__like_t<_Self, _Fn>, _Args...>>()))
+ {
+ return !std::__invoke(__like_t<_Self, _Not_fn>(__self)._M_fn,
+ std::forward<_Args>(__args)...);
+ }
+# pragma GCC diagnostic pop
+#else
// Macro to define operator() with given cv-qualifiers ref-qualifiers,
// forwarding _M_fn and the function arguments with the same qualifiers,
// and deducing the return type and exception-specification.
@@ -1081,6 +1179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_NOT_FN_CALL_OP( && )
_GLIBCXX_NOT_FN_CALL_OP( const && )
#undef _GLIBCXX_NOT_FN_CALL_OP
+#endif
private:
_Fn _M_fn;
diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index b3105c5..b81ee78 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -1259,7 +1259,9 @@ namespace views::__adaptor
// Invoke _Adaptor with arguments __r, _M_args... according to the
// value category of this _Partial object.
-#if __cpp_explicit_this_parameter
+#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this
template<typename _Self, typename _Range>
requires __adaptor_invocable<_Adaptor, _Range, __like_t<_Self, _Args>...>
constexpr auto
@@ -1268,6 +1270,7 @@ namespace views::__adaptor
return _Binder::_S_call(__like_t<_Self, _Partial>(__self)._M_binder,
std::forward<_Range>(__r));
}
+# pragma GCC diagnostic pop
#else
template<typename _Range>
requires __adaptor_invocable<_Adaptor, _Range, const _Args&...>
@@ -1336,7 +1339,9 @@ namespace views::__adaptor
// Invoke _M_rhs(_M_lhs(__r)) according to the value category of this
// range adaptor closure object.
-#if __cpp_explicit_this_parameter
+#if _GLIBCXX_EXPLICIT_THIS_PARAMETER
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wc++23-extensions" // deducing this
template<typename _Self, typename _Range>
requires __pipe_invocable<__like_t<_Self, _Lhs>, __like_t<_Self, _Rhs>, _Range>
constexpr auto
@@ -1346,6 +1351,7 @@ namespace views::__adaptor
(__like_t<_Self, _Pipe>(__self)._M_lhs
(std::forward<_Range>(__r))));
}
+# pragma GCC diagnostic pop
#else
template<typename _Range>
requires __pipe_invocable<const _Lhs&, const _Rhs&, _Range>
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 5c09fac..7c157ea 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -41,6 +41,7 @@
#define __glibcxx_want_bool_constant
#define __glibcxx_want_bounded_array_traits
+#define __glibcxx_want_common_reference
#define __glibcxx_want_constant_wrapper
#define __glibcxx_want_has_unique_object_representations
#define __glibcxx_want_integral_constant_callable
@@ -4225,7 +4226,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
{ using type = _Tp0; };
/// @cond undocumented
- template<typename _Tp1, typename _Tp2, int _Bullet = 1, typename = void>
+ template<typename _Tp1, typename _Tp2, int _Bullet = 1>
struct __common_reference_impl
: __common_reference_impl<_Tp1, _Tp2, _Bullet + 1>
{ };
@@ -4238,46 +4239,38 @@ template<typename _Ret, typename _Fn, typename... _Args>
// If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, ...
template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1&, _Tp2&, 1,
- void_t<__common_ref<_Tp1&, _Tp2&>>>
- { using type = __common_ref<_Tp1&, _Tp2&>; };
-
- template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1&&, _Tp2&&, 1,
- void_t<__common_ref<_Tp1&&, _Tp2&&>>>
- { using type = __common_ref<_Tp1&&, _Tp2&&>; };
-
- template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1&, _Tp2&&, 1,
- void_t<__common_ref<_Tp1&, _Tp2&&>>>
- { using type = __common_ref<_Tp1&, _Tp2&&>; };
-
- template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1&&, _Tp2&, 1,
- void_t<__common_ref<_Tp1&&, _Tp2&>>>
- { using type = __common_ref<_Tp1&&, _Tp2&>; };
+ requires is_reference_v<_Tp1> && is_reference_v<_Tp2>
+ && requires { typename __common_ref<_Tp1, _Tp2>; }
+#if __cpp_lib_common_reference // C++ >= 20
+ && is_convertible_v<add_pointer_t<_Tp1>,
+ add_pointer_t<__common_ref<_Tp1, _Tp2>>>
+ && is_convertible_v<add_pointer_t<_Tp2>,
+ add_pointer_t<__common_ref<_Tp1, _Tp2>>>
+#endif
+ struct __common_reference_impl<_Tp1, _Tp2, 1>
+ { using type = __common_ref<_Tp1, _Tp2>; };
// Otherwise, if basic_common_reference<...>::type is well-formed, ...
template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1, _Tp2, 2,
- void_t<__basic_common_ref<_Tp1, _Tp2>>>
+ requires requires { typename __basic_common_ref<_Tp1, _Tp2>; }
+ struct __common_reference_impl<_Tp1, _Tp2, 2>
{ using type = __basic_common_ref<_Tp1, _Tp2>; };
// Otherwise, if COND-RES(T1, T2) is well-formed, ...
template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1, _Tp2, 3,
- void_t<__cond_res<_Tp1, _Tp2>>>
+ requires requires { typename __cond_res<_Tp1, _Tp2>; }
+ struct __common_reference_impl<_Tp1, _Tp2, 3>
{ using type = __cond_res<_Tp1, _Tp2>; };
// Otherwise, if common_type_t<T1, T2> is well-formed, ...
template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1, _Tp2, 4,
- void_t<common_type_t<_Tp1, _Tp2>>>
+ requires requires { typename common_type_t<_Tp1, _Tp2>; }
+ struct __common_reference_impl<_Tp1, _Tp2, 4>
{ using type = common_type_t<_Tp1, _Tp2>; };
// Otherwise, there shall be no member type.
template<typename _Tp1, typename _Tp2>
- struct __common_reference_impl<_Tp1, _Tp2, 5, void>
+ struct __common_reference_impl<_Tp1, _Tp2, 5>
{ };
// Otherwise, if sizeof...(T) is greater than two, ...
@@ -4296,7 +4289,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
{ };
/// @endcond
-#endif // C++2a
+#endif // C++20
#if __cplusplus >= 201103L
// Stores a tuple of indices. Used by tuple and pair, and by bind() to