30#ifndef _GLIBCXX_MOF_CV
31# define _GLIBCXX_MOF_CV
34namespace std _GLIBCXX_VISIBILITY(default)
36_GLIBCXX_BEGIN_NAMESPACE_VERSION
41 template<
bool _Noex,
typename _Ret,
typename _Class,
typename... _Args>
42 struct __skip_first_arg<_Ret(_Class::*)(_Args...) _GLIBCXX_MOF_CV
44 {
using type = _Ret(_Args...) noexcept(_Noex); };
46 template<
bool _Noex, typename _Ret, typename _Class, typename... _Args>
47 struct __skip_first_arg<_Ret(_Class::*)(_Args...) _GLIBCXX_MOF_CV&
49 {
using type = _Ret(_Args...) noexcept(_Noex); };
67 template<typename _Res, typename... _ArgTypes,
bool _Noex>
72 (std::__is_complete_or_unbounded(__type_identity<_ArgTypes>()) && ...),
73 "each parameter type must be a complete class");
75 using _Invoker = __polyfunc::_Invoker<_Noex, _Res, _ArgTypes...>;
76 using _Signature = _Invoker::_Signature;
79 template<
typename... _Tps>
80 static constexpr bool __is_invocable_using
81 = __conditional_t<_Noex,
82 is_nothrow_invocable_r<_Res, _Tps..., _ArgTypes...>,
83 is_invocable_r<_Res, _Tps..., _ArgTypes...>>::value;
87 template<
typename _Fn>
88 requires is_function_v<_Fn> && __is_invocable_using<_Fn*>
91 __glibcxx_assert(__fn !=
nullptr);
92 _M_invoke = _Invoker::template _S_ptrs<_Fn*>();
97 template<
typename _Fn,
typename _Vt = remove_reference_t<_Fn>>
98 requires (!is_same_v<remove_cv_t<_Vt>, function_ref>)
99 && (!is_member_pointer_v<_Vt>)
104 && (!is_function_v<_Vt>)
105 && __is_invocable_using<_Vt _GLIBCXX_MOF_CV&>
109 using _Fd = remove_cv_t<_Vt>;
110 if constexpr (__is_std_op_wrapper<_Fd>)
112 _M_invoke = _Invoker::template _S_nttp<_Fd{}>;
113 _M_ptrs._M_obj =
nullptr;
115 else if constexpr (
requires (_ArgTypes&&... __args) {
119 _M_invoke = _Invoker::template _S_static<_Fd>;
120 _M_ptrs._M_obj =
nullptr;
124 _M_invoke = _Invoker::template _S_ptrs<_Vt _GLIBCXX_MOF_CV&>();
132 template<auto __cwfn,
typename _Fn>
133 requires __is_invocable_using<const _Fn&>
137 constexpr const _Fn& __fn = constant_wrapper<__cwfn, _Fn>::value;
138 if constexpr (
sizeof...(_ArgTypes) > 0)
139 if constexpr ((... && _ConstExprParam<remove_cvref_t<_ArgTypes>>))
140 static_assert(!
requires {
141 typename constant_wrapper<
143 },
"cw<fn>(args...) should be equivalent to fn(args...)");
145 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
146 static_assert(__fn !=
nullptr);
148 _M_invoke = &_Invoker::template _S_nttp<__fn>;
149 _M_ptrs._M_obj =
nullptr;
154 template<
auto __cwfn,
typename _Fn,
typename _Up,
156 requires (!is_rvalue_reference_v<_Up&&>)
157 && __is_invocable_using<const _Fn&, _Td _GLIBCXX_MOF_CV&>
161 constexpr const _Fn& __fn = constant_wrapper<__cwfn, _Fn>::value;
162 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
163 static_assert(__fn !=
nullptr);
165 if constexpr (is_member_pointer_v<_Fn>
169 _M_invoke = &_Invoker::template _S_bind_ptr<__fn, _Td _GLIBCXX_MOF_CV>;
171 _M_invoke = &_Invoker::template _S_bind_ref<__fn, _Td _GLIBCXX_MOF_CV&>;
177 template< auto __cwfn,
typename _Fn,
typename _Td>
178 requires __is_invocable_using<const _Fn&, _Td _GLIBCXX_MOF_CV*>
180 function_ref(constant_wrapper<__cwfn, _Fn>, _Td _GLIBCXX_MOF_CV* __ptr)
noexcept
182 constexpr const _Fn& __fn = constant_wrapper<__cwfn, _Fn>::value;
183 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
184 static_assert(__fn !=
nullptr);
185 if constexpr (is_member_pointer_v<_Fn>)
186 __glibcxx_assert(__ptr !=
nullptr);
188 _M_invoke = &_Invoker::template _S_bind_ptr<__fn, _Td _GLIBCXX_MOF_CV>;
192 template<
typename _Tp>
193 requires (!is_same_v<_Tp, function_ref>) && (!is_pointer_v<_Tp>)
194 && (!__is_constant_wrapper_v<_Tp>)
196 operator=(_Tp) =
delete;
209 template<
typename _Tp>
211 _M_init(_Tp* __ptr)
noexcept
213 if constexpr (is_function_v<_Tp>)
214 _M_ptrs._M_func =
reinterpret_cast<void(*)()
>(__ptr);
216 _M_ptrs._M_obj = __ptr;
219 typename _Invoker::__ptrs_func_t _M_invoke;
220 __polyfunc::_Ptrs _M_ptrs;
223#undef _GLIBCXX_MOF_CV
225_GLIBCXX_END_NAMESPACE_VERSION
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
constexpr function_ref(_Fn &&__f) noexcept
Target and bound object is object referenced by parameter.
function_ref(_Fn *__fn) noexcept
Target and bound object is function pointed by parameter.
constexpr function_ref(constant_wrapper< __cwfn, _Fn >, _Td _GLIBCXX_MOF_CV *__ptr) noexcept
Target object is equivalent to std::bind_front<_fn>(__ptr). Bound object is object pointed by second ...
constexpr function_ref(constant_wrapper< __cwfn, _Fn >) noexcept
Target object is __fn. There is no bound object.
_Res operator()(_ArgTypes... __args) const noexcept(_Noex)
constexpr function_ref(constant_wrapper< __cwfn, _Fn >, _Up &&__ref) noexcept
Target object is equivalent to std::bind_front<_fn>(std::ref(__ref)). Bound object is object referenc...
[concept.same], concept same_as