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>
70 : __polyfunc::_Ref_base
73 (std::__is_complete_or_unbounded(__type_identity<_ArgTypes>()) && ...),
74 "each parameter type must be a complete class");
76 using _Base = __polyfunc::_Ref_base;
77 using _Invoker = __polyfunc::_Invoker<_Noex, _Res, _ArgTypes...>;
78 using _ArgsSignature = _Res(_ArgTypes...)
noexcept(_Noex);
79 using _TargetQuals =
int _GLIBCXX_MOF_CV&;
82 template<
typename... _Tps>
83 static constexpr bool __is_invocable_using
84 = __conditional_t<_Noex,
85 is_nothrow_invocable_r<_Res, _Tps..., _ArgTypes...>,
86 is_invocable_r<_Res, _Tps..., _ArgTypes...>>::value;
90 template<
typename _Fn>
91 requires is_function_v<_Fn> && __is_invocable_using<_Fn*>
94 __glibcxx_assert(__fn !=
nullptr);
96 _M_invoke = _Invoker::template _S_ptrs<_Fn*>();
100 template<
typename _Fn,
typename _Vt = remove_reference_t<_Fn>>
101 requires (!is_same_v<remove_cv_t<_Vt>, function_ref>)
102 && (!is_member_pointer_v<_Vt>)
107 && (!is_function_v<_Vt>)
108 && __is_invocable_using<_Vt _GLIBCXX_MOF_CV&>
112 using _Fd = remove_cv_t<_Vt>;
113 if constexpr (__is_std_op_wrapper<_Fd>)
114 _M_invoke = _Invoker::template _S_nttp<_Fd{}>;
115 else if constexpr (
requires (_ArgTypes&&... __args) {
118 _M_invoke = _Invoker::template _S_static<_Fd>;
119 else if constexpr (__is_function_ref_v<_Fd>
120 && __polyfunc::__is_invoker_convertible<_Fd, function_ref>())
122 _Base::operator=(__polyfunc::__base_of(__f));
123 _M_invoke = __polyfunc::__invoker_of(__f);
128 _M_invoke = _Invoker::template _S_ptrs<_Vt _GLIBCXX_MOF_CV&>();
135 template<auto __cwfn,
typename _Fn>
136 requires __is_invocable_using<const _Fn&>
140 constexpr const _Fn& __fn = constant_wrapper<__cwfn, _Fn>::value;
141 if constexpr (
sizeof...(_ArgTypes) > 0)
142 if constexpr ((... && _ConstExprParam<remove_cvref_t<_ArgTypes>>))
143 static_assert(!
requires {
144 typename constant_wrapper<
146 },
"cw<fn>(args...) should be equivalent to fn(args...)");
148 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
149 static_assert(__fn !=
nullptr);
151 _M_invoke = &_Invoker::template _S_nttp<__fn>;
156 template<
auto __cwfn,
typename _Fn,
typename _Up,
158 requires (!is_rvalue_reference_v<_Up&&>)
159 && __is_invocable_using<const _Fn&, _Td _GLIBCXX_MOF_CV&>
163 constexpr const _Fn& __fn = constant_wrapper<__cwfn, _Fn>::value;
164 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
165 static_assert(__fn !=
nullptr);
168 if constexpr (is_member_pointer_v<_Fn>
172 _M_invoke = &_Invoker::template _S_bind_ptr<__fn, _Td _GLIBCXX_MOF_CV>;
174 _M_invoke = &_Invoker::template _S_bind_ref<__fn, _Td _GLIBCXX_MOF_CV&>;
179 template< auto __cwfn,
typename _Fn,
typename _Td>
180 requires __is_invocable_using<const _Fn&, _Td _GLIBCXX_MOF_CV*>
182 function_ref(constant_wrapper<__cwfn, _Fn>, _Td _GLIBCXX_MOF_CV* __ptr)
noexcept
184 constexpr const _Fn& __fn = constant_wrapper<__cwfn, _Fn>::value;
185 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
186 static_assert(__fn !=
nullptr);
187 if constexpr (is_member_pointer_v<_Fn>)
188 __glibcxx_assert(__ptr !=
nullptr);
191 _M_invoke = &_Invoker::template _S_bind_ptr<__fn, _Td _GLIBCXX_MOF_CV>;
194 template<
typename _Tp>
195 requires (!is_same_v<_Tp, function_ref>)
196 && (!is_pointer_v<_Tp>)
197 && (!__is_constant_wrapper_v<_Tp>)
198 && (!__polyfunc::__is_funcref_assignable<function_ref, _Tp>())
200 operator=(_Tp) =
delete;
213 typename _Invoker::__ptrs_func_t _M_invoke;
215 template<
typename _Func>
216 friend constexpr auto&
217 __polyfunc::__invoker_of(_Func&)
noexcept;
219 template<
typename _Func>
220 friend constexpr auto&
221 __polyfunc::__base_of(_Func&)
noexcept;
223 template<
typename _Src,
typename _Dst>
224 friend consteval bool
225 __polyfunc::__is_invoker_convertible() noexcept;
227 template<typename _Dst, typename _Src>
228 friend consteval
bool
229 __polyfunc::__is_funcref_assignable() noexcept;
232#undef _GLIBCXX_MOF_CV
234_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.
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 ...
_Res operator()(_ArgTypes... __args) const noexcept(_Noex)
constexpr function_ref(constant_wrapper< __cwfn, _Fn >) noexcept
Target object is __fn. There is no bound object.
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...
function_ref(_Fn *__fn) noexcept
Target and bound object is function pointed by parameter.
[concept.same], concept same_as