4242// return std::invoke_r(std::forward<Args>(args)...);
4343// }
4444//
45- // template <class Ret, class Func, class... Args>
46- // inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>;
47- //
4845// template <class Func, class... Args>
4946// struct __is_invocable : is_invocable<Func, Args...> {};
5047//
5148// template <class Func, class... Args>
5249// inline const bool __is_invocable_v = is_invocable_v<Func, Args...>;
5350//
51+ // template <class Ret, class Func, class... Args>
52+ // inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>;
53+ //
5454// template <class Func, class... Args>
5555// inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>;
5656//
5757// template <class Func, class... Args>
58+ // inline const bool __is_nothrow_invocable_r_v = is_nothrow_invocable_r_v<Func, Args...>;
59+ //
60+ // template <class Func, class... Args>
5861// struct __invoke_result : invoke_result {};
5962//
6063// template <class Func, class... Args>
@@ -126,46 +129,6 @@ template <class _Ret, class... _Args>
126129inline const bool __is_nothrow_invocable_r_v =
127130 __is_nothrow_invocable_r_impl<__is_nothrow_invocable_v<_Args...>, _Ret, _Args...>;
128131
129- # if _LIBCPP_STD_VER >= 17
130-
131- // is_invocable
132-
133- template <class _Fn , class ... _Args>
134- struct _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...> > {};
135-
136- template <class _Ret , class _Fn , class ... _Args>
137- struct _LIBCPP_NO_SPECIALIZATIONS is_invocable_r : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
138-
139- template <class _Fn , class ... _Args>
140- _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>;
141-
142- template <class _Ret , class _Fn , class ... _Args>
143- _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
144-
145- // is_nothrow_invocable
146-
147- template <class _Fn , class ... _Args>
148- struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable : bool_constant<__is_nothrow_invocable_v<_Fn, _Args...> > {};
149-
150- template <class _Ret , class _Fn , class ... _Args>
151- struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r
152- : integral_constant<bool , __is_nothrow_invocable_r_v<_Ret, _Fn, _Args...>> {};
153-
154- template <class _Fn , class ... _Args>
155- _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = __is_nothrow_invocable_v<_Fn, _Args...>;
156-
157- template <class _Ret , class _Fn , class ... _Args>
158- _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v =
159- __is_nothrow_invocable_r_v<_Ret, _Fn, _Args...>;
160-
161- template <class _Fn , class ... _Args>
162- struct _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {};
163-
164- template <class _Fn , class ... _Args>
165- using invoke_result_t = __invoke_result_t <_Fn, _Args...>;
166-
167- # endif // _LIBCPP_STD_VER >= 17
168-
169132#else // __has_builtin(__builtin_invoke)
170133
171134template <class _DecayedFp >
@@ -352,19 +315,45 @@ inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::val
352315template <class _Func , class ... _Args>
353316inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value;
354317
318+ template <class _Ret , class _Func , class ... _Args>
319+ inline const bool __is_nothrow_invocable_r_v = __nothrow_invokable_r<_Ret, _Func, _Args...>::value;
320+
355321template <class _Func , class ... _Args>
356322struct __invoke_result
357323 : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void , _Func, _Args...>::_Result> {};
358324
359325template <class _Func , class ... _Args>
360326using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type;
361327
362- # if _LIBCPP_STD_VER >= 17
328+ #endif // __has_builtin(__builtin_invoke_r)
329+
330+ template <class _Ret , bool = is_void<_Ret>::value>
331+ struct __invoke_void_return_wrapper {
332+ template <class ... _Args>
333+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static _Ret __call (_Args&&... __args) {
334+ return std::__invoke (std::forward<_Args>(__args)...);
335+ }
336+ };
337+
338+ template <class _Ret >
339+ struct __invoke_void_return_wrapper <_Ret, true > {
340+ template <class ... _Args>
341+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void __call (_Args&&... __args) {
342+ std::__invoke (std::forward<_Args>(__args)...);
343+ }
344+ };
345+
346+ template <class _Ret , class ... _Args>
347+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r (_Args&&... __args) {
348+ return __invoke_void_return_wrapper<_Ret>::__call (std::forward<_Args>(__args)...);
349+ }
350+
351+ #if _LIBCPP_STD_VER >= 17
363352
364353// is_invocable
365354
366355template <class _Fn , class ... _Args>
367- struct _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...>> {};
356+ struct _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...> > {};
368357
369358template <class _Ret , class _Fn , class ... _Args>
370359struct _LIBCPP_NO_SPECIALIZATIONS is_invocable_r : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
@@ -378,49 +367,26 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocab
378367// is_nothrow_invocable
379368
380369template <class _Fn , class ... _Args>
381- struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable : bool_constant<__nothrow_invokable <_Fn, _Args...>::value > {};
370+ struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable : bool_constant<__is_nothrow_invocable_v <_Fn, _Args...> > {};
382371
383372template <class _Ret , class _Fn , class ... _Args>
384373struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r
385- : bool_constant<__nothrow_invokable_r <_Ret, _Fn, _Args...>::value > {};
374+ : bool_constant<__is_nothrow_invocable_r_v <_Ret, _Fn, _Args...>> {};
386375
387376template <class _Fn , class ... _Args>
388- _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable <_Fn, _Args...>::value ;
377+ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = __is_nothrow_invocable_v <_Fn, _Args...>;
389378
390379template <class _Ret , class _Fn , class ... _Args>
391380_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v =
392- is_nothrow_invocable_r <_Ret, _Fn, _Args...>::value ;
381+ __is_nothrow_invocable_r_v <_Ret, _Fn, _Args...>;
393382
394383template <class _Fn , class ... _Args>
395384struct _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {};
396385
397386template <class _Fn , class ... _Args>
398- using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;
399-
400- # endif // _LIBCPP_STD_VER >= 17
401-
402- #endif // __has_builtin(__builtin_invoke_r)
403-
404- template <class _Ret , bool = is_void<_Ret>::value>
405- struct __invoke_void_return_wrapper {
406- template <class ... _Args>
407- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static _Ret __call (_Args&&... __args) {
408- return std::__invoke (std::forward<_Args>(__args)...);
409- }
410- };
411-
412- template <class _Ret >
413- struct __invoke_void_return_wrapper <_Ret, true > {
414- template <class ... _Args>
415- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void __call (_Args&&... __args) {
416- std::__invoke (std::forward<_Args>(__args)...);
417- }
418- };
387+ using invoke_result_t = __invoke_result_t <_Fn, _Args...>;
419388
420- template <class _Ret , class ... _Args>
421- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r (_Args&&... __args) {
422- return __invoke_void_return_wrapper<_Ret>::__call (std::forward<_Args>(__args)...);
423- }
389+ #endif
424390
425391_LIBCPP_END_NAMESPACE_STD
426392
0 commit comments