Skip to content

Commit 0fa0545

Browse files
authored
[libc++] Define an internal API for std::invoke and friends (llvm#116637)
Currently we're using quite different internal names for the `std::invoke` family of type traits. This adds a layer around the current implementation to make it easier to understand when it is used and makes it easier to define multiple implementations of it.
1 parent c248fc1 commit 0fa0545

File tree

17 files changed

+109
-66
lines changed

17 files changed

+109
-66
lines changed

libcxx/include/__algorithm/make_projected.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ struct _ProjectedPred {
3434
: __pred(__pred_arg), __proj(__proj_arg) {}
3535

3636
template <class _Tp>
37-
typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))>::type
38-
_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
39-
operator()(_Tp&& __v) const {
37+
__invoke_result_t<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))> _LIBCPP_CONSTEXPR
38+
_LIBCPP_HIDE_FROM_ABI
39+
operator()(_Tp&& __v) const {
4040
return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
4141
}
4242

4343
template <class _T1, class _T2>
44-
typename __invoke_of<_Pred&,
45-
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
46-
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))>::type _LIBCPP_CONSTEXPR
44+
__invoke_result_t<_Pred&,
45+
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
46+
decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))> _LIBCPP_CONSTEXPR
4747
_LIBCPP_HIDE_FROM_ABI
4848
operator()(_T1&& __lhs, _T2&& __rhs) const {
4949
return std::__invoke(

libcxx/include/__algorithm/radix_sort.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ __partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator
8888

8989
template <class _Value, class _Map, class _Radix>
9090
struct __radix_sort_traits {
91-
using __image_type _LIBCPP_NODEBUG = decay_t<typename __invoke_of<_Map, _Value>::type>;
91+
using __image_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Map, _Value>>;
9292
static_assert(is_unsigned<__image_type>::value);
9393

94-
using __radix_type _LIBCPP_NODEBUG = decay_t<typename __invoke_of<_Radix, __image_type>::type>;
94+
using __radix_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Radix, __image_type>>;
9595
static_assert(is_integral<__radix_type>::value);
9696

9797
static constexpr auto __radix_value_range = numeric_limits<__radix_type>::max() + 1;
@@ -101,7 +101,7 @@ struct __radix_sort_traits {
101101

102102
template <class _Value, class _Map>
103103
struct __counting_sort_traits {
104-
using __image_type _LIBCPP_NODEBUG = decay_t<typename __invoke_of<_Map, _Value>::type>;
104+
using __image_type _LIBCPP_NODEBUG = decay_t<__invoke_result_t<_Map, _Value>>;
105105
static_assert(is_unsigned<__image_type>::value);
106106

107107
static constexpr const auto __value_range = numeric_limits<__image_type>::max() + 1;
@@ -158,7 +158,7 @@ _LIBCPP_HIDE_FROM_ABI bool __collect_impl(
158158
using __value_type = __iter_value_type<_ForwardIterator>;
159159
constexpr auto __radix_value_range = __radix_sort_traits<__value_type, _Map, _Radix>::__radix_value_range;
160160

161-
auto __previous = numeric_limits<typename __invoke_of<_Map, __value_type>::type>::min();
161+
auto __previous = numeric_limits<__invoke_result_t<_Map, __value_type>>::min();
162162
auto __is_sorted = true;
163163
std::for_each(__first, __last, [&__counters, &__map, &__radix, &__previous, &__is_sorted](const auto& __value) {
164164
auto __current = __map(__value);

libcxx/include/__functional/bind.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w
8282
}
8383

8484
template <class _Ti, class... _Uj, size_t... _Indx>
85-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type
85+
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...>
8686
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) {
8787
return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...);
8888
}
8989

9090
template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
91-
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type
91+
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...>
9292
__mu(_Ti& __ti, tuple<_Uj...>& __uj) {
9393
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
9494
return std::__mu_expand(__ti, __uj, __indices());
@@ -130,12 +130,12 @@ struct __mu_return_invokable // false
130130

131131
template <class _Ti, class... _Uj>
132132
struct __mu_return_invokable<true, _Ti, _Uj...> {
133-
typedef typename __invoke_of<_Ti&, _Uj...>::type type;
133+
using type = __invoke_result_t<_Ti&, _Uj...>;
134134
};
135135

136136
template <class _Ti, class... _Uj>
137137
struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
138-
: public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> {};
138+
: public __mu_return_invokable<__is_invocable_v<_Ti&, _Uj...>, _Ti, _Uj...> {};
139139

140140
template <class _Ti, class _TupleUj>
141141
struct __mu_return_impl<_Ti, false, false, true, _TupleUj> {
@@ -168,25 +168,25 @@ struct __is_valid_bind_return {
168168

169169
template <class _Fp, class... _BoundArgs, class _TupleUj>
170170
struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> {
171-
static const bool value = __invokable<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
171+
static const bool value = __is_invocable_v<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>;
172172
};
173173

174174
template <class _Fp, class... _BoundArgs, class _TupleUj>
175175
struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> {
176-
static const bool value = __invokable<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
176+
static const bool value = __is_invocable_v<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>;
177177
};
178178

179179
template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
180180
struct __bind_return;
181181

182182
template <class _Fp, class... _BoundArgs, class _TupleUj>
183183
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
184-
typedef typename __invoke_of< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >::type type;
184+
using type = __invoke_result_t< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >;
185185
};
186186

187187
template <class _Fp, class... _BoundArgs, class _TupleUj>
188188
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
189-
typedef typename __invoke_of< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >::type type;
189+
using type = __invoke_result_t< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >;
190190
};
191191

192192
template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
@@ -256,8 +256,7 @@ class __bind_r : public __bind<_Fp, _BoundArgs...> {
256256
is_void<_Rp>::value,
257257
int> = 0>
258258
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) {
259-
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
260-
return _Invoker::__call(static_cast<base&>(*this), std::forward<_Args>(__args)...);
259+
return std::__invoke_r<_Rp>(static_cast<base&>(*this), std::forward<_Args>(__args)...);
261260
}
262261

263262
template <class... _Args,
@@ -266,8 +265,7 @@ class __bind_r : public __bind<_Fp, _BoundArgs...> {
266265
is_void<_Rp>::value,
267266
int> = 0>
268267
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const {
269-
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
270-
return _Invoker::__call(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
268+
return std::__invoke_r<_Rp>(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
271269
}
272270
};
273271

libcxx/include/__functional/function.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> {
164164
: __func_(std::move(__f)), __alloc_(std::move(__a)) {}
165165

166166
_LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {
167-
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
168-
return _Invoker::__call(__func_, std::forward<_ArgTypes>(__arg)...);
167+
return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...);
169168
}
170169

171170
_LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const {
@@ -213,8 +212,7 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
213212
_LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
214213

215214
_LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {
216-
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
217-
return _Invoker::__call(__f_, std::forward<_ArgTypes>(__arg)...);
215+
return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...);
218216
}
219217

220218
_LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const {
@@ -841,12 +839,12 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
841839
__func __f_;
842840

843841
template <class _Fp,
844-
bool = _And< _IsNotSame<__remove_cvref_t<_Fp>, function>, __invokable<_Fp, _ArgTypes...> >::value>
842+
bool = _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable<_Fp, _ArgTypes...> >::value>
845843
struct __callable;
846844
template <class _Fp>
847845
struct __callable<_Fp, true> {
848846
static const bool value =
849-
is_void<_Rp>::value || __is_core_convertible<typename __invoke_of<_Fp, _ArgTypes...>::type, _Rp>::value;
847+
is_void<_Rp>::value || __is_core_convertible<__invoke_result_t<_Fp, _ArgTypes...>, _Rp>::value;
850848
};
851849
template <class _Fp>
852850
struct __callable<_Fp, false> {

libcxx/include/__functional/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ template <class _Key, class _Hash>
522522
using __check_hash_requirements _LIBCPP_NODEBUG =
523523
integral_constant<bool,
524524
is_copy_constructible<_Hash>::value && is_move_constructible<_Hash>::value &&
525-
__invokable_r<size_t, _Hash, _Key const&>::value >;
525+
__is_invocable_r_v<size_t, _Hash, _Key const&> >;
526526

527527
template <class _Key, class _Hash = hash<_Key> >
528528
using __has_enabled_hash _LIBCPP_NODEBUG =

libcxx/include/__functional/mem_fn.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class __mem_fn : public __weak_result_type<_Tp> {
3636

3737
// invoke
3838
template <class... _ArgTypes>
39-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<const _Tp&, _ArgTypes...>::type
40-
operator()(_ArgTypes&&... __args) const _NOEXCEPT_(__nothrow_invokable<const _Tp&, _ArgTypes...>::value) {
39+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<const _Tp&, _ArgTypes...>
40+
operator()(_ArgTypes&&... __args) const _NOEXCEPT_(__is_nothrow_invocable_v<const _Tp&, _ArgTypes...>) {
4141
return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
4242
}
4343
};

libcxx/include/__functional/reference_wrapper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {
5757

5858
// invoke
5959
template <class... _ArgTypes>
60-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<type&, _ArgTypes...>::type
60+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<type&, _ArgTypes...>
6161
operator()(_ArgTypes&&... __args) const
6262
#if _LIBCPP_STD_VER >= 17
6363
// Since is_nothrow_invocable requires C++17 LWG3764 is not backported

libcxx/include/__hash_table

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,9 @@ struct __enforce_unordered_container_requirements {
650650

651651
template <class _Key, class _Hash, class _Equal>
652652
#ifndef _LIBCPP_CXX03_LANG
653-
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
653+
_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Equal const&, _Key const&, _Key const&>,
654654
"the specified comparator type does not provide a viable const call operator")
655-
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
655+
_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Hash const&, _Key const&>,
656656
"the specified hash functor does not provide a viable const call operator")
657657
#endif
658658
typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type

libcxx/include/__tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ private:
876876

877877
template <class _Tp, class _Compare>
878878
#ifndef _LIBCPP_CXX03_LANG
879-
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
879+
_LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp const&>,
880880
"the specified comparator type does not provide a viable const call operator")
881881
#endif
882882
int __diagnose_non_const_comparator();

libcxx/include/__type_traits/invoke.h

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,36 @@
2929
# pragma GCC system_header
3030
#endif
3131

32+
// This file defines the following libc++-internal API (back-ported to C++03):
33+
//
34+
// template <class... Args>
35+
// decltype(auto) __invoke(Args&&... args) noexcept(noexcept(std::invoke(std::forward<Args>(args...)))) {
36+
// return std::invoke(std::forward<Args>(args)...);
37+
// }
38+
//
39+
// template <class Ret, class... Args>
40+
// Ret __invoke_r(Args&&... args) {
41+
// return std::invoke_r(std::forward<Args>(args)...);
42+
// }
43+
//
44+
// template <class Ret, class Func, class... Args>
45+
// inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>;
46+
//
47+
// template <class Func, class... Args>
48+
// struct __is_invocable : is_invocable<Func, Args...> {};
49+
//
50+
// template <class Func, class... Args>
51+
// inline const bool __is_invocable_v = is_invocable_v<Func, Args...>;
52+
//
53+
// template <class Func, class... Args>
54+
// inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>;
55+
//
56+
// template <class Func, class... Args>
57+
// struct __invoke_result : invoke_result {};
58+
//
59+
// template <class Func, class... Args>
60+
// using __invoke_result_t = invoke_result_t<Func, Args...>;
61+
3262
_LIBCPP_BEGIN_NAMESPACE_STD
3363

3464
template <class _DecayedFp>
@@ -167,7 +197,7 @@ struct __invokable_r {
167197
static const bool value = type::value;
168198
};
169199
template <class _Fp, class... _Args>
170-
using __invokable _LIBCPP_NODEBUG = __invokable_r<void, _Fp, _Args...>;
200+
using __is_invocable _LIBCPP_NODEBUG = __invokable_r<void, _Fp, _Args...>;
171201

172202
template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class... _Args>
173203
struct __nothrow_invokable_r_imp {
@@ -204,11 +234,7 @@ using __nothrow_invokable_r _LIBCPP_NODEBUG =
204234

205235
template <class _Fp, class... _Args>
206236
using __nothrow_invokable _LIBCPP_NODEBUG =
207-
__nothrow_invokable_r_imp<__invokable<_Fp, _Args...>::value, true, void, _Fp, _Args...>;
208-
209-
template <class _Fp, class... _Args>
210-
struct __invoke_of
211-
: public enable_if<__invokable<_Fp, _Args...>::value, typename __invokable_r<void, _Fp, _Args...>::_Result> {};
237+
__nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>;
212238

213239
template <class _Ret, bool = is_void<_Ret>::value>
214240
struct __invoke_void_return_wrapper {
@@ -226,31 +252,51 @@ struct __invoke_void_return_wrapper<_Ret, true> {
226252
}
227253
};
228254

255+
template <class _Func, class... _Args>
256+
inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value;
257+
258+
template <class _Ret, class _Func, class... _Args>
259+
inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::value;
260+
261+
template <class _Func, class... _Args>
262+
inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value;
263+
264+
template <class _Func, class... _Args>
265+
struct __invoke_result
266+
: enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {};
267+
268+
template <class _Func, class... _Args>
269+
using __invoke_result_t = typename __invoke_result<_Func, _Args...>::type;
270+
271+
template <class _Ret, class... _Args>
272+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) {
273+
return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...);
274+
}
275+
229276
#if _LIBCPP_STD_VER >= 17
230277

231278
// is_invocable
232279

233280
template <class _Fn, class... _Args>
234-
struct _LIBCPP_TEMPLATE_VIS is_invocable : integral_constant<bool, __invokable<_Fn, _Args...>::value> {};
281+
struct _LIBCPP_TEMPLATE_VIS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...>> {};
235282

236283
template <class _Ret, class _Fn, class... _Args>
237-
struct _LIBCPP_TEMPLATE_VIS is_invocable_r : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {};
284+
struct _LIBCPP_TEMPLATE_VIS is_invocable_r : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
238285

239286
template <class _Fn, class... _Args>
240-
inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value;
287+
inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>;
241288

242289
template <class _Ret, class _Fn, class... _Args>
243-
inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value;
290+
inline constexpr bool is_invocable_r_v = __is_invocable_r_v<_Ret, _Fn, _Args...>;
244291

245292
// is_nothrow_invocable
246293

247294
template <class _Fn, class... _Args>
248-
struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {
249-
};
295+
struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable : bool_constant<__nothrow_invokable<_Fn, _Args...>::value> {};
250296

251297
template <class _Ret, class _Fn, class... _Args>
252-
struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r
253-
: integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
298+
struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r : bool_constant<__nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {
299+
};
254300

255301
template <class _Fn, class... _Args>
256302
inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
@@ -259,7 +305,7 @@ template <class _Ret, class _Fn, class... _Args>
259305
inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;
260306

261307
template <class _Fn, class... _Args>
262-
struct _LIBCPP_TEMPLATE_VIS invoke_result : __invoke_of<_Fn, _Args...> {};
308+
struct _LIBCPP_TEMPLATE_VIS invoke_result : __invoke_result<_Fn, _Args...> {};
263309

264310
template <class _Fn, class... _Args>
265311
using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;

libcxx/include/__type_traits/result_of.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222

2323
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2424
template <class _Callable>
25-
class _LIBCPP_DEPRECATED_IN_CXX17 result_of;
25+
struct _LIBCPP_DEPRECATED_IN_CXX17 result_of;
2626

2727
template <class _Fp, class... _Args>
28-
class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> {};
28+
struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};
2929

3030
# if _LIBCPP_STD_VER >= 14
3131
template <class _Tp>

libcxx/include/future

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ class _LIBCPP_HIDDEN __async_func {
18401840
tuple<_Fp, _Args...> __f_;
18411841

18421842
public:
1843-
typedef typename __invoke_of<_Fp, _Args...>::type _Rp;
1843+
using _Rp = __invoke_result_t<_Fp, _Args...>;
18441844

18451845
_LIBCPP_HIDE_FROM_ABI explicit __async_func(_Fp&& __f, _Args&&... __args)
18461846
: __f_(std::move(__f), std::move(__args)...) {}
@@ -1864,7 +1864,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch
18641864
}
18651865

18661866
template <class _Fp, class... _Args>
1867-
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>
1867+
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> >
18681868
async(launch __policy, _Fp&& __f, _Args&&... __args) {
18691869
typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF;
18701870
typedef typename _BF::_Rp _Rp;
@@ -1889,7 +1889,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) {
18891889
}
18901890

18911891
template <class _Fp, class... _Args>
1892-
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>
1892+
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> >
18931893
async(_Fp&& __f, _Args&&... __args) {
18941894
return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...);
18951895
}

0 commit comments

Comments
 (0)