Skip to content

Commit 1cfc1e7

Browse files
authored
Mitigate the C2039 about retired std::result_of. (#567)
1 parent 6772122 commit 1cfc1e7

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

Rx/v2/src/rxcpp/operators/rx-concat_map.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ struct member_overload<concat_map_tag>
305305
template<class Observable, class CollectionSelector,
306306
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
307307
class SourceValue = rxu::value_type_t<Observable>,
308-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
308+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
309309
class ResultSelectorType = rxu::detail::take_at<1>,
310310
class Enabled = rxu::enable_if_all_true_type_t<
311311
all_observables<Observable, CollectionType>>,
312312
class ConcatMap = rxo::detail::concat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, ResultSelectorType, identity_one_worker>,
313313
class CollectionValueType = rxu::value_type_t<CollectionType>,
314-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
314+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
315315
class Result = observable<Value, ConcatMap>
316316
>
317317
static Result member(Observable&& o, CollectionSelector&& s) {
@@ -321,14 +321,14 @@ struct member_overload<concat_map_tag>
321321
template<class Observable, class CollectionSelector, class Coordination,
322322
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
323323
class SourceValue = rxu::value_type_t<Observable>,
324-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
324+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
325325
class ResultSelectorType = rxu::detail::take_at<1>,
326326
class Enabled = rxu::enable_if_all_true_type_t<
327327
all_observables<Observable, CollectionType>,
328328
is_coordination<Coordination>>,
329329
class ConcatMap = rxo::detail::concat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, ResultSelectorType, rxu::decay_t<Coordination>>,
330330
class CollectionValueType = rxu::value_type_t<CollectionType>,
331-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
331+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
332332
class Result = observable<Value, ConcatMap>
333333
>
334334
static Result member(Observable&& o, CollectionSelector&& s, Coordination&& cn) {
@@ -339,14 +339,14 @@ struct member_overload<concat_map_tag>
339339
class IsCoordination = is_coordination<ResultSelector>,
340340
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
341341
class SourceValue = rxu::value_type_t<Observable>,
342-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
342+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
343343
class Enabled = rxu::enable_if_all_true_type_t<
344344
all_observables<Observable, CollectionType>,
345345
rxu::negation<IsCoordination>>,
346346
class ConcatMap = rxo::detail::concat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, rxu::decay_t<ResultSelector>, identity_one_worker>,
347347
class CollectionValueType = rxu::value_type_t<CollectionType>,
348348
class ResultSelectorType = rxu::decay_t<ResultSelector>,
349-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
349+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
350350
class Result = observable<Value, ConcatMap>
351351
>
352352
static Result member(Observable&& o, CollectionSelector&& s, ResultSelector&& rs) {
@@ -356,14 +356,14 @@ struct member_overload<concat_map_tag>
356356
template<class Observable, class CollectionSelector, class ResultSelector, class Coordination,
357357
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
358358
class SourceValue = rxu::value_type_t<Observable>,
359-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
359+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
360360
class Enabled = rxu::enable_if_all_true_type_t<
361361
all_observables<Observable, CollectionType>,
362362
is_coordination<Coordination>>,
363363
class ConcatMap = rxo::detail::concat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, rxu::decay_t<ResultSelector>, rxu::decay_t<Coordination>>,
364364
class CollectionValueType = rxu::value_type_t<CollectionType>,
365365
class ResultSelectorType = rxu::decay_t<ResultSelector>,
366-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
366+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
367367
class Result = observable<Value, ConcatMap>
368368
>
369369
static Result member(Observable&& o, CollectionSelector&& s, ResultSelector&& rs, Coordination&& cn) {

Rx/v2/src/rxcpp/operators/rx-flat_map.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ struct member_overload<flat_map_tag>
263263
template<class Observable, class CollectionSelector,
264264
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
265265
class SourceValue = rxu::value_type_t<Observable>,
266-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
266+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
267267
class ResultSelectorType = rxu::detail::take_at<1>,
268268
class Enabled = rxu::enable_if_all_true_type_t<
269269
all_observables<Observable, CollectionType>>,
270270
class FlatMap = rxo::detail::flat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, ResultSelectorType, identity_one_worker>,
271271
class CollectionValueType = rxu::value_type_t<CollectionType>,
272-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
272+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
273273
class Result = observable<Value, FlatMap>
274274
>
275275
static Result member(Observable&& o, CollectionSelector&& s) {
@@ -279,14 +279,14 @@ struct member_overload<flat_map_tag>
279279
template<class Observable, class CollectionSelector, class Coordination,
280280
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
281281
class SourceValue = rxu::value_type_t<Observable>,
282-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
282+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
283283
class ResultSelectorType = rxu::detail::take_at<1>,
284284
class Enabled = rxu::enable_if_all_true_type_t<
285285
all_observables<Observable, CollectionType>,
286286
is_coordination<Coordination>>,
287287
class FlatMap = rxo::detail::flat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, ResultSelectorType, rxu::decay_t<Coordination>>,
288288
class CollectionValueType = rxu::value_type_t<CollectionType>,
289-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
289+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
290290
class Result = observable<Value, FlatMap>
291291
>
292292
static Result member(Observable&& o, CollectionSelector&& s, Coordination&& cn) {
@@ -297,14 +297,14 @@ struct member_overload<flat_map_tag>
297297
class IsCoordination = is_coordination<ResultSelector>,
298298
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
299299
class SourceValue = rxu::value_type_t<Observable>,
300-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
300+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
301301
class Enabled = rxu::enable_if_all_true_type_t<
302302
all_observables<Observable, CollectionType>,
303303
rxu::negation<IsCoordination>>,
304304
class FlatMap = rxo::detail::flat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, rxu::decay_t<ResultSelector>, identity_one_worker>,
305305
class CollectionValueType = rxu::value_type_t<CollectionType>,
306306
class ResultSelectorType = rxu::decay_t<ResultSelector>,
307-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
307+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
308308
class Result = observable<Value, FlatMap>
309309
>
310310
static Result member(Observable&& o, CollectionSelector&& s, ResultSelector&& rs) {
@@ -314,14 +314,14 @@ struct member_overload<flat_map_tag>
314314
template<class Observable, class CollectionSelector, class ResultSelector, class Coordination,
315315
class CollectionSelectorType = rxu::decay_t<CollectionSelector>,
316316
class SourceValue = rxu::value_type_t<Observable>,
317-
class CollectionType = rxu::result_of_t<CollectionSelectorType(SourceValue)>,
317+
class CollectionType = rxu::callable_result_t<CollectionSelectorType, SourceValue>,
318318
class Enabled = rxu::enable_if_all_true_type_t<
319319
all_observables<Observable, CollectionType>,
320320
is_coordination<Coordination>>,
321321
class FlatMap = rxo::detail::flat_map<rxu::decay_t<Observable>, rxu::decay_t<CollectionSelector>, rxu::decay_t<ResultSelector>, rxu::decay_t<Coordination>>,
322322
class CollectionValueType = rxu::value_type_t<CollectionType>,
323323
class ResultSelectorType = rxu::decay_t<ResultSelector>,
324-
class Value = rxu::result_of_t<ResultSelectorType(SourceValue, CollectionValueType)>,
324+
class Value = rxu::callable_result_t<ResultSelectorType, SourceValue, CollectionValueType>,
325325
class Result = observable<Value, FlatMap>
326326
>
327327
static Result member(Observable&& o, CollectionSelector&& s, ResultSelector&& rs, Coordination&& cn) {

Rx/v2/src/rxcpp/operators/rx-window_toggle.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct window_toggle
5757
using openings_type = rxu::decay_t<Openings>;
5858
using openings_value_type = typename openings_type::value_type;
5959
using closing_selector_type = rxu::decay_t<ClosingSelector>;
60-
using closings_type = rxu::result_of_t<closing_selector_type(openings_value_type)>;
60+
using closings_type = rxu::callable_result_t<closing_selector_type, openings_value_type>;
6161
using closings_value_type = typename closings_type::value_type;
6262

6363
struct window_toggle_values
@@ -287,7 +287,7 @@ struct member_overload<window_toggle_tag>
287287
class OpeningsType = rxu::decay_t<Openings>,
288288
class OpeningsValueType = typename OpeningsType::value_type,
289289
class Enabled = rxu::enable_if_all_true_type_t<
290-
all_observables<Observable, Openings, rxu::result_of_t<ClosingSelectorType(OpeningsValueType)>>>,
290+
all_observables<Observable, Openings, rxu::callable_result_t<ClosingSelectorType, OpeningsValueType>>>,
291291
class SourceValue = rxu::value_type_t<Observable>,
292292
class WindowToggle = rxo::detail::window_toggle<SourceValue, rxu::decay_t<Openings>, rxu::decay_t<ClosingSelector>, identity_one_worker>,
293293
class Value = observable<SourceValue>>
@@ -301,7 +301,7 @@ struct member_overload<window_toggle_tag>
301301
class OpeningsType = rxu::decay_t<Openings>,
302302
class OpeningsValueType = typename OpeningsType::value_type,
303303
class Enabled = rxu::enable_if_all_true_type_t<
304-
all_observables<Observable, Openings, rxu::result_of_t<ClosingSelectorType(OpeningsValueType)>>,
304+
all_observables<Observable, Openings, rxu::callable_result_t<ClosingSelectorType, OpeningsValueType>>,
305305
is_coordination<Coordination>>,
306306
class SourceValue = rxu::value_type_t<Observable>,
307307
class WindowToggle = rxo::detail::window_toggle<SourceValue, rxu::decay_t<Openings>, rxu::decay_t<ClosingSelector>, rxu::decay_t<Coordination>>,

Rx/v2/src/rxcpp/rx-util.hpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
#define RXCPP_MAKE_IDENTIFIER(Prefix) RXCPP_CONCAT_EVALUATE(Prefix, __LINE__)
3030

31+
#define RXCPP_DECLVAL(...) static_cast<__VA_ARGS__ (*)() noexcept>(nullptr)()
32+
3133
// Provide replacements for try/catch keywords, using which is a compilation error
3234
// when exceptions are disabled with -fno-exceptions.
3335
#if RXCPP_USE_EXCEPTIONS
@@ -46,18 +48,13 @@ namespace util {
4648

4749
template<class T> using value_type_t = typename std::decay<T>::type::value_type;
4850
template<class T> using decay_t = typename std::decay<T>::type;
49-
#ifdef __cpp_lib_is_invocable
50-
template <class> struct result_of;
5151

52-
template <class F, class... TN>
53-
struct result_of<F(TN...)>
54-
{
55-
using type = std::invoke_result_t<F, TN...>;
52+
template <typename Fn, typename... ArgTypes>
53+
struct callable_result {
54+
using type = decltype(RXCPP_DECLVAL(Fn&&)(RXCPP_DECLVAL(ArgTypes&&)...));
5655
};
57-
#else
58-
template<class... TN> using result_of = std::result_of<TN...>;
59-
#endif
60-
template<class... TN> using result_of_t = typename result_of<TN...>::type;
56+
template <typename Fn, typename... ArgTypes>
57+
using callable_result_t = typename callable_result<Fn, ArgTypes...>::type;
6158

6259
template<class T, std::size_t size>
6360
std::vector<T> to_vector(const T (&arr) [size]) {
@@ -1027,7 +1024,7 @@ struct is_hashable<T,
10271024
typename rxu::types_checked_from<
10281025
typename filtered_hash<T>::result_type,
10291026
typename filtered_hash<T>::argument_type,
1030-
typename rxu::result_of<filtered_hash<T>(T)>::type>::type>
1027+
typename rxu::callable_result<filtered_hash<T>, T>::type>::type>
10311028
: std::true_type {};
10321029

10331030
}

0 commit comments

Comments
 (0)