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 __fn,
typename _Fn>
136 requires __is_invocable_using<const _Fn&>
140 if constexpr (
sizeof...(_ArgTypes) > 0)
141 if constexpr ((... && _ConstExprParam<remove_cvref_t<_ArgTypes>>))
142 static_assert(!
requires {
143 typename constant_wrapper<
145 },
"cw<fn>(args...) should be equivalent to fn(args...)");
147 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
148 static_assert(__fn !=
nullptr);
150 _M_invoke = &_Invoker::template _S_nttp<__fn>;
155 template<
auto __fn,
typename _Fn,
typename _Up,
157 requires (!is_rvalue_reference_v<_Up&&>)
158 && __is_invocable_using<const _Fn&, _Td _GLIBCXX_MOF_CV&>
162 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
163 static_assert(__fn !=
nullptr);
166 if constexpr (is_member_pointer_v<_Fn>
170 _M_invoke = &_Invoker::template _S_bind_ptr<__fn, _Td _GLIBCXX_MOF_CV>;
172 _M_invoke = &_Invoker::template _S_bind_ref<__fn, _Td _GLIBCXX_MOF_CV&>;
177 template<auto __fn,
typename _Fn,
typename _Td>
178 requires __is_invocable_using<const _Fn&, _Td _GLIBCXX_MOF_CV*>
180 function_ref(constant_wrapper<__fn, _Fn>, _Td _GLIBCXX_MOF_CV* __ptr)
noexcept
182 if constexpr (is_pointer_v<_Fn> || is_member_pointer_v<_Fn>)
183 static_assert(__fn !=
nullptr);
184 if constexpr (is_member_pointer_v<_Fn>)
185 __glibcxx_assert(__ptr !=
nullptr);
188 _M_invoke = &_Invoker::template _S_bind_ptr<__fn, _Td _GLIBCXX_MOF_CV>;
191 template<
typename _Tp>
192 requires (!is_same_v<_Tp, function_ref>)
193 && (!is_pointer_v<_Tp>)
194 && (!__is_constant_wrapper_v<_Tp>)
195 && (!__polyfunc::__is_funcref_assignable<function_ref, _Tp>())
197 operator=(_Tp) =
delete;
210 typename _Invoker::__ptrs_func_t _M_invoke;
212 template<
typename _Func>
213 friend constexpr auto&
214 __polyfunc::__invoker_of(_Func&)
noexcept;
216 template<
typename _Func>
217 friend constexpr auto&
218 __polyfunc::__base_of(_Func&)
noexcept;
220 template<
typename _Src,
typename _Dst>
221 friend consteval bool
222 __polyfunc::__is_invoker_convertible() noexcept;
224 template<typename _Dst, typename _Src>
225 friend consteval
bool
226 __polyfunc::__is_funcref_assignable() noexcept;
229#undef _GLIBCXX_MOF_CV
231_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< __fn, _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< __fn, _Fn >) noexcept
Target object is __fn. There is no bound object.
_Res operator()(_ArgTypes... __args) const noexcept(_Noex)
constexpr function_ref(constant_wrapper< __fn, _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