|
42 | 42 | // return std::invoke_r(std::forward<Args>(args)...);
|
43 | 43 | // }
|
44 | 44 | //
|
45 |
| -// template <class Ret, class Func, class... Args> |
46 |
| -// inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>; |
47 |
| -// |
48 | 45 | // template <class Func, class... Args>
|
49 | 46 | // struct __is_invocable : is_invocable<Func, Args...> {};
|
50 | 47 | //
|
51 | 48 | // template <class Func, class... Args>
|
52 | 49 | // inline const bool __is_invocable_v = is_invocable_v<Func, Args...>;
|
53 | 50 | //
|
| 51 | +// template <class Ret, class Func, class... Args> |
| 52 | +// inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>; |
| 53 | +// |
54 | 54 | // template <class Func, class... Args>
|
55 | 55 | // inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>;
|
56 | 56 | //
|
57 | 57 | // 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> |
58 | 61 | // struct __invoke_result : invoke_result {};
|
59 | 62 | //
|
60 | 63 | // template <class Func, class... Args>
|
@@ -126,46 +129,6 @@ template <class _Ret, class... _Args>
|
126 | 129 | inline const bool __is_nothrow_invocable_r_v =
|
127 | 130 | __is_nothrow_invocable_r_impl<__is_nothrow_invocable_v<_Args...>, _Ret, _Args...>;
|
128 | 131 |
|
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 |
| - |
169 | 132 | #else // __has_builtin(__builtin_invoke)
|
170 | 133 |
|
171 | 134 | template <class _DecayedFp>
|
@@ -352,75 +315,78 @@ inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::val
|
352 | 315 | template <class _Func, class... _Args>
|
353 | 316 | inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value;
|
354 | 317 |
|
| 318 | +template <class _Ret, class _Func, class... _Args> |
| 319 | +inline const bool __is_nothrow_invocable_r_v = __nothrow_invokable_r<_Ret, _Fn, _Args...>::value; |
| 320 | + |
355 | 321 | template <class _Func, class... _Args>
|
356 | 322 | struct __invoke_result
|
357 | 323 | : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {};
|
358 | 324 |
|
359 | 325 | template <class _Func, class... _Args>
|
360 | 326 | using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type;
|
361 | 327 |
|
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 |
363 | 352 |
|
364 | 353 | // is_invocable
|
365 | 354 |
|
366 | 355 | template <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...> > {}; |
368 | 357 |
|
369 | 358 | template <class _Ret, class _Fn, class... _Args>
|
370 | 359 | struct _LIBCPP_NO_SPECIALIZATIONS is_invocable_r : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
|
371 | 360 |
|
372 | 361 | template <class _Fn, class... _Args>
|
373 | 362 | _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>;
|
374 | 363 |
|
375 |
| -template <class _Ret, class _Fn, class... _Args> |
376 |
| -_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocable_r_v<_Ret, _Fn, _Args...>; |
| 364 | +template <class _Fn, class... _Args> |
| 365 | +_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocable_r_v<_Fn, _Args...>; |
377 | 366 |
|
378 | 367 | // is_nothrow_invocable
|
379 | 368 |
|
380 | 369 | template <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...> > {}; |
382 | 371 |
|
383 | 372 | template <class _Ret, class _Fn, class... _Args>
|
384 | 373 | struct _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...>> {}; |
386 | 375 |
|
387 | 376 | template <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...>; |
389 | 378 |
|
390 | 379 | template <class _Ret, class _Fn, class... _Args>
|
391 | 380 | _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...>; |
393 | 382 |
|
394 | 383 | template <class _Fn, class... _Args>
|
395 | 384 | struct _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {};
|
396 | 385 |
|
397 | 386 | template <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...>; |
419 | 388 |
|
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 |
424 | 390 |
|
425 | 391 | _LIBCPP_END_NAMESPACE_STD
|
426 | 392 |
|
|
0 commit comments