From 3a61031e508d9dc38676129e1ec8d01c3fd488a6 Mon Sep 17 00:00:00 2001 From: rstein Date: Mon, 14 Mar 2022 18:02:29 +0100 Subject: [PATCH 1/2] make cmake enforce C++14 standard see https://github.com/ReactiveX/RxCpp/pull/572#issuecomment-1066465190-permalink --- projects/CMake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 2b3d57e97..d01c0fb1f 100755 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.2 FATAL_ERROR) project(rxcpp VERSION 2.2.4 LANGUAGES C CXX) +set(CMAKE_CXX_STANDARD 14) set_property(GLOBAL PROPERTY USE_FOLDERS ON) From d295d6539954432e8c277356b815bd258d710d2a Mon Sep 17 00:00:00 2001 From: rstein Date: Mon, 14 Mar 2022 19:38:16 +0100 Subject: [PATCH 2/2] added rxcpp::is_same_v C++14 compatible definition in view of C++17's `std::is_same_v` --- .../src/rxcpp/operators/rx-combine_latest.hpp | 2 +- Rx/v2/src/rxcpp/operators/rx-concat_map.hpp | 4 ++-- Rx/v2/src/rxcpp/operators/rx-flat_map.hpp | 4 ++-- Rx/v2/src/rxcpp/operators/rx-group_by.hpp | 2 +- Rx/v2/src/rxcpp/operators/rx-reduce.hpp | 2 +- .../rxcpp/operators/rx-with_latest_from.hpp | 2 +- Rx/v2/src/rxcpp/operators/rx-zip.hpp | 2 +- Rx/v2/src/rxcpp/rx-connectable_observable.hpp | 2 +- Rx/v2/src/rxcpp/rx-grouped_observable.hpp | 2 +- Rx/v2/src/rxcpp/rx-notification.hpp | 2 +- Rx/v2/src/rxcpp/rx-observable-fwd.hpp | 2 +- Rx/v2/src/rxcpp/rx-observable.hpp | 6 ++--- Rx/v2/src/rxcpp/rx-observer.hpp | 20 ++++++++-------- Rx/v2/src/rxcpp/rx-predef.hpp | 8 +++---- Rx/v2/src/rxcpp/rx-scheduler.hpp | 2 +- Rx/v2/src/rxcpp/rx-subscriber.hpp | 4 ++-- Rx/v2/src/rxcpp/rx-subscription.hpp | 4 ++-- Rx/v2/src/rxcpp/rx-test.hpp | 2 +- Rx/v2/src/rxcpp/rx-trace.hpp | 24 +++++++++++++++++++ Rx/v2/src/rxcpp/sources/rx-error.hpp | 8 +++---- Rx/v2/src/rxcpp/sources/rx-iterate.hpp | 2 +- 21 files changed, 65 insertions(+), 41 deletions(-) diff --git a/Rx/v2/src/rxcpp/operators/rx-combine_latest.hpp b/Rx/v2/src/rxcpp/operators/rx-combine_latest.hpp index 150deb0c5..1a8f8ac0e 100644 --- a/Rx/v2/src/rxcpp/operators/rx-combine_latest.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-combine_latest.hpp @@ -68,7 +68,7 @@ struct is_combine_latest_selector_check { using type = decltype(check...>(0)); - static const bool value = !std::is_same_v; + static const bool value = !rxcpp::is_same_v; }; template diff --git a/Rx/v2/src/rxcpp/operators/rx-concat_map.hpp b/Rx/v2/src/rxcpp/operators/rx-concat_map.hpp index ba91e6619..bd6767811 100644 --- a/Rx/v2/src/rxcpp/operators/rx-concat_map.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-concat_map.hpp @@ -64,7 +64,7 @@ struct concat_traits { template static tag_not_valid collection_check(...); - static_assert(!std::is_same_v(0)), tag_not_valid>, "concat_map CollectionSelector must be a function with the signature observable(concat_map::source_value_type)"); + static_assert(!rxcpp::is_same_v(0)), tag_not_valid>, "concat_map CollectionSelector must be a function with the signature observable(concat_map::source_value_type)"); using collection_type = decltype(std::declval()((*(source_value_type *) nullptr))); @@ -79,7 +79,7 @@ struct concat_traits { template static tag_not_valid result_check(...); - static_assert(!std::is_same_v(0)), tag_not_valid>, "concat_map ResultSelector must be a function with the signature concat_map::value_type(concat_map::source_value_type, concat_map::collection_value_type)"); + static_assert(!rxcpp::is_same_v(0)), tag_not_valid>, "concat_map ResultSelector must be a function with the signature concat_map::value_type(concat_map::source_value_type, concat_map::collection_value_type)"); using value_type = rxu::decay_t()(std::declval(), std::declval()))> ; }; diff --git a/Rx/v2/src/rxcpp/operators/rx-flat_map.hpp b/Rx/v2/src/rxcpp/operators/rx-flat_map.hpp index 9a15824a5..25ae56924 100644 --- a/Rx/v2/src/rxcpp/operators/rx-flat_map.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-flat_map.hpp @@ -64,7 +64,7 @@ struct flat_map_traits { template static tag_not_valid collection_check(...); - static_assert(!std::is_same_v(0)), tag_not_valid>, "flat_map CollectionSelector must be a function with the signature observable(flat_map::source_value_type)"); + static_assert(!rxcpp::is_same_v(0)), tag_not_valid>, "flat_map CollectionSelector must be a function with the signature observable(flat_map::source_value_type)"); using collection_type = rxu::decay_t()(std::declval()))>; @@ -77,7 +77,7 @@ struct flat_map_traits { template static tag_not_valid result_check(...); - static_assert(!std::is_same_v(0)), tag_not_valid>, "flat_map ResultSelector must be a function with the signature flat_map::value_type(flat_map::source_value_type, flat_map::collection_value_type)"); + static_assert(!rxcpp::is_same_v(0)), tag_not_valid>, "flat_map ResultSelector must be a function with the signature flat_map::value_type(flat_map::source_value_type, flat_map::collection_value_type)"); using value_type = rxu::decay_t())(std::declval(), std::declval()))> ; }; diff --git a/Rx/v2/src/rxcpp/operators/rx-group_by.hpp b/Rx/v2/src/rxcpp/operators/rx-group_by.hpp index 76a7a345d..855edc029 100644 --- a/Rx/v2/src/rxcpp/operators/rx-group_by.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-group_by.hpp @@ -61,7 +61,7 @@ struct is_group_by_selector_for { static tag_not_valid check(...); using type = decltype(check(0)); - static const bool value = !std::is_same_v; + static const bool value = !rxcpp::is_same_v; }; template diff --git a/Rx/v2/src/rxcpp/operators/rx-reduce.hpp b/Rx/v2/src/rxcpp/operators/rx-reduce.hpp index 724d4f7ae..79eb87265 100644 --- a/Rx/v2/src/rxcpp/operators/rx-reduce.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-reduce.hpp @@ -78,7 +78,7 @@ struct is_result_function_for { static tag_not_valid check(...); using type = rxu::decay_t(0))>; - static const bool value = !std::is_same_v; + static const bool value = !rxcpp::is_same_v; }; template diff --git a/Rx/v2/src/rxcpp/operators/rx-with_latest_from.hpp b/Rx/v2/src/rxcpp/operators/rx-with_latest_from.hpp index 4b201e2e3..001c36da4 100644 --- a/Rx/v2/src/rxcpp/operators/rx-with_latest_from.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-with_latest_from.hpp @@ -68,7 +68,7 @@ struct is_with_latest_from_selector_check { using type = decltype(check...>(0)); - static const bool value = !std::is_same_v; + static const bool value = !rxcpp::is_same_v; }; template diff --git a/Rx/v2/src/rxcpp/operators/rx-zip.hpp b/Rx/v2/src/rxcpp/operators/rx-zip.hpp index 3b605dd5f..1a4b56d32 100644 --- a/Rx/v2/src/rxcpp/operators/rx-zip.hpp +++ b/Rx/v2/src/rxcpp/operators/rx-zip.hpp @@ -103,7 +103,7 @@ struct is_zip_selector_check { using type = decltype(check...>(0)); - static const bool value = !std::is_same_v; + static const bool value = !rxcpp::is_same_v; }; template diff --git a/Rx/v2/src/rxcpp/rx-connectable_observable.hpp b/Rx/v2/src/rxcpp/rx-connectable_observable.hpp index c94ce0172..14be47c28 100644 --- a/Rx/v2/src/rxcpp/rx-connectable_observable.hpp +++ b/Rx/v2/src/rxcpp/rx-connectable_observable.hpp @@ -21,7 +21,7 @@ struct has_on_connect static not_void check(...); using detail_result = decltype(check(0)); - static const bool value = std::is_same_v; + static const bool value = rxcpp::is_same_v; }; } diff --git a/Rx/v2/src/rxcpp/rx-grouped_observable.hpp b/Rx/v2/src/rxcpp/rx-grouped_observable.hpp index cbecd5eb8..a6e2d5926 100644 --- a/Rx/v2/src/rxcpp/rx-grouped_observable.hpp +++ b/Rx/v2/src/rxcpp/rx-grouped_observable.hpp @@ -21,7 +21,7 @@ struct has_on_get_key_for static not_void check(...); using detail_result = decltype(check(0)); - static const bool value = std::is_same_v>; + static const bool value = rxcpp::is_same_v>; }; } diff --git a/Rx/v2/src/rxcpp/rx-notification.hpp b/Rx/v2/src/rxcpp/rx-notification.hpp index 330ddb924..5f71db25d 100644 --- a/Rx/v2/src/rxcpp/rx-notification.hpp +++ b/Rx/v2/src/rxcpp/rx-notification.hpp @@ -229,7 +229,7 @@ struct notification template static type on_error(Exception&& e) { - return make_on_error(typename std::conditional_t, rxu::error_ptr>, exception_ptr_tag, exception_tag>(), std::forward(e)); + return make_on_error(typename std::conditional_t, rxu::error_ptr>, exception_ptr_tag, exception_tag>(), std::forward(e)); } }; diff --git a/Rx/v2/src/rxcpp/rx-observable-fwd.hpp b/Rx/v2/src/rxcpp/rx-observable-fwd.hpp index a02ca61a8..45ad7287f 100644 --- a/Rx/v2/src/rxcpp/rx-observable-fwd.hpp +++ b/Rx/v2/src/rxcpp/rx-observable-fwd.hpp @@ -14,7 +14,7 @@ class dynamic_observable; template< class T = void, - class SourceObservable = typename std::conditional_t, void, dynamic_observable>> + class SourceObservable = typename std::conditional_t, void, dynamic_observable>> class observable; template diff --git a/Rx/v2/src/rxcpp/rx-observable.hpp b/Rx/v2/src/rxcpp/rx-observable.hpp index aef5b07c2..80cbc042f 100644 --- a/Rx/v2/src/rxcpp/rx-observable.hpp +++ b/Rx/v2/src/rxcpp/rx-observable.hpp @@ -27,7 +27,7 @@ struct has_on_subscribe_for static not_void check(...); using detail_result = decltype(check, T > (0)); - static const bool value = std::is_same_v; + static const bool value = rxcpp::is_same_v; }; } @@ -478,7 +478,7 @@ template class observable : public observable_base { - static_assert(std::is_same_v, "SourceOperator::value_type must be the same as T in observable"); + static_assert(rxcpp::is_same_v, "SourceOperator::value_type must be the same as T in observable"); using this_type = observable; @@ -501,7 +501,7 @@ class observable using subscriber_type = rxu::decay_t; static_assert(is_subscriber::value, "subscribe must be passed a subscriber"); - static_assert(std::is_same_v && std::is_convertible::value, "the value types in the sequence must match or be convertible"); + static_assert(rxcpp::is_same_v && std::is_convertible::value, "the value types in the sequence must match or be convertible"); static_assert(detail::has_on_subscribe_for::value, "inner must have on_subscribe method that accepts this subscriber "); trace_activity().subscribe_enter(*this, o); diff --git a/Rx/v2/src/rxcpp/rx-observer.hpp b/Rx/v2/src/rxcpp/rx-observer.hpp index c39ca71cd..53e316e74 100644 --- a/Rx/v2/src/rxcpp/rx-observer.hpp +++ b/Rx/v2/src/rxcpp/rx-observer.hpp @@ -121,7 +121,7 @@ struct is_on_next_of static not_void check(...); using detail_result = decltype(check>(0)); - static const bool value = std::is_same_v; + static const bool value = rxcpp::is_same_v; }; template @@ -133,7 +133,7 @@ struct is_on_error template static not_void check(...); - static const bool value = std::is_same_v>(0)), void>; + static const bool value = rxcpp::is_same_v>(0)), void>; }; template @@ -145,7 +145,7 @@ struct is_on_error_for template static not_void check(...); - static const bool value = std::is_same_v>(0)), void>; + static const bool value = rxcpp::is_same_v>(0)), void>; }; template @@ -157,7 +157,7 @@ struct is_on_completed template static not_void check(...); - static const bool value = std::is_same_v>(0)), void>; + static const bool value = rxcpp::is_same_v>(0)), void>; }; } @@ -181,9 +181,9 @@ class observer : public observer_base public: using this_type = observer; using state_t = rxu::decay_t; - using on_next_t = typename std::conditional_t, rxu::decay_t, detail::OnNextForward>; - using on_error_t = typename std::conditional_t, rxu::decay_t, detail::OnErrorForward>; - using on_completed_t = typename std::conditional_t, rxu::decay_t, detail::OnCompletedForward>; + using on_next_t = typename std::conditional_t, rxu::decay_t, detail::OnNextForward>; + using on_error_t = typename std::conditional_t, rxu::decay_t, detail::OnErrorForward>; + using on_completed_t = typename std::conditional_t, rxu::decay_t, detail::OnCompletedForward>; private: mutable state_t state; @@ -261,9 +261,9 @@ class observer { public: using this_type = observer; - using on_next_t = typename std::conditional_t, rxu::decay_t, detail::OnNextEmpty>; - using on_error_t = typename std::conditional_t, rxu::decay_t, detail::OnErrorEmpty>; - using on_completed_t = typename std::conditional_t, rxu::decay_t, detail::OnCompletedEmpty>; + using on_next_t = typename std::conditional_t, rxu::decay_t, detail::OnNextEmpty>; + using on_error_t = typename std::conditional_t, rxu::decay_t, detail::OnErrorEmpty>; + using on_completed_t = typename std::conditional_t, rxu::decay_t, detail::OnCompletedEmpty>; private: on_next_t onnext; diff --git a/Rx/v2/src/rxcpp/rx-predef.hpp b/Rx/v2/src/rxcpp/rx-predef.hpp index f6e92e172..e840d5c9f 100644 --- a/Rx/v2/src/rxcpp/rx-predef.hpp +++ b/Rx/v2/src/rxcpp/rx-predef.hpp @@ -202,7 +202,7 @@ template class dynamic_connectable_observable; template, void, dynamic_connectable_observable>> + class SourceObservable = typename std::conditional_t, void, dynamic_connectable_observable>> class connectable_observable; struct tag_connectable_observable : public tag_observable {}; @@ -235,7 +235,7 @@ template class dynamic_grouped_observable; template, void, dynamic_grouped_observable>> + class SourceObservable = typename std::conditional_t, void, dynamic_grouped_observable>> class grouped_observable; template @@ -268,7 +268,7 @@ struct is_operator_factory_for { using type = decltype(check(0)); - static const bool value = !std::is_same_v && is_observable::value; + static const bool value = !rxcpp::is_same_v && is_observable::value; }; // @@ -307,7 +307,7 @@ struct is_accumulate_function_for { static tag_not_valid check(...); using type = decltype(check(0)); - static const bool value = std::is_same_v; + static const bool value = rxcpp::is_same_v; }; } diff --git a/Rx/v2/src/rxcpp/rx-scheduler.hpp b/Rx/v2/src/rxcpp/rx-scheduler.hpp index 9214142a4..558fb24d0 100644 --- a/Rx/v2/src/rxcpp/rx-scheduler.hpp +++ b/Rx/v2/src/rxcpp/rx-scheduler.hpp @@ -187,7 +187,7 @@ struct is_action_function template static not_void check(...); - static const bool value = std::is_same_v>(0)), void>; + static const bool value = rxcpp::is_same_v>(0)), void>; }; } diff --git a/Rx/v2/src/rxcpp/rx-subscriber.hpp b/Rx/v2/src/rxcpp/rx-subscriber.hpp index 1f9c7ede0..4b95b0bc1 100644 --- a/Rx/v2/src/rxcpp/rx-subscriber.hpp +++ b/Rx/v2/src/rxcpp/rx-subscriber.hpp @@ -124,8 +124,8 @@ class subscriber : public subscriber_base subscriber( const subscriber& o, typename std::enable_if< - !std::is_same_v> && - std::is_same_v>, void**>::type = nullptr) + !rxcpp::is_same_v> && + rxcpp::is_same_v>, void**>::type = nullptr) : lifetime(o.lifetime) , destination(o.destination.as_dynamic()) , id(o.id) diff --git a/Rx/v2/src/rxcpp/rx-subscription.hpp b/Rx/v2/src/rxcpp/rx-subscription.hpp index d98f5fbeb..bb8b1c820 100644 --- a/Rx/v2/src/rxcpp/rx-subscription.hpp +++ b/Rx/v2/src/rxcpp/rx-subscription.hpp @@ -20,7 +20,7 @@ struct is_unsubscribe_function template static not_void check(...); - static const bool value = std::is_same_v>(0)), void>; + static const bool value = rxcpp::is_same_v>(0)), void>; }; } @@ -143,7 +143,7 @@ class subscription : public subscription_base } } template - explicit subscription(U u, typename std::enable_if && is_subscription::value, void**>::type = nullptr) + explicit subscription(U u, typename std::enable_if && is_subscription::value, void**>::type = nullptr) // intentionally slice : state(std::move((*static_cast(&u)).state)) { diff --git a/Rx/v2/src/rxcpp/rx-test.hpp b/Rx/v2/src/rxcpp/rx-test.hpp index d0ecd90e6..95e0bc196 100644 --- a/Rx/v2/src/rxcpp/rx-test.hpp +++ b/Rx/v2/src/rxcpp/rx-test.hpp @@ -38,7 +38,7 @@ struct test_source ts->on_subscribe(std::move(o)); } template - typename std::enable_if>, void>::type + typename std::enable_if>, void>::type on_subscribe(Subscriber o) const { static_assert(is_subscriber::value, "on_subscribe must be passed a subscriber."); diff --git a/Rx/v2/src/rxcpp/rx-trace.hpp b/Rx/v2/src/rxcpp/rx-trace.hpp index bf0abaf0a..9c4df2e43 100644 --- a/Rx/v2/src/rxcpp/rx-trace.hpp +++ b/Rx/v2/src/rxcpp/rx-trace.hpp @@ -111,4 +111,28 @@ struct trace_tag {}; inline auto rxcpp_trace_activity(...) -> rxcpp::trace_noop; +#if __cplusplus <= 201402L +// intermediate C++14 hort-hand definitions anticipating those available in C++17 onwards +namespace rxcpp { +template +static constexpr bool is_same_v = false; + +template +static constexpr bool is_same_v = true; + +} // namespace rxcpp + +#else + +namespace rxcpp { +template +inline constexpr bool is_same_v = std::is_same_v<_Tp, _Up>; + +} // namespace rxcpp +#endif + +static_assert(rxcpp::is_same_v); +static_assert(!rxcpp::is_same_v); + + #endif diff --git a/Rx/v2/src/rxcpp/sources/rx-error.hpp b/Rx/v2/src/rxcpp/sources/rx-error.hpp index 0ffc70caa..79ae0f030 100644 --- a/Rx/v2/src/rxcpp/sources/rx-error.hpp +++ b/Rx/v2/src/rxcpp/sources/rx-error.hpp @@ -115,15 +115,15 @@ namespace sources { */ template auto error(E e) - -> decltype(detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), identity_immediate())) { - return detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), identity_immediate()); + -> decltype(detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), identity_immediate())) { + return detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), identity_immediate()); } /*! @copydoc rx-error.hpp */ template auto error(E e, Coordination cn) - -> decltype(detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), std::move(cn))) { - return detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), std::move(cn)); + -> decltype(detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), std::move(cn))) { + return detail::make_error(typename std::conditional_t>, detail::throw_ptr_tag, detail::throw_instance_tag>(), std::move(e), std::move(cn)); } } diff --git a/Rx/v2/src/rxcpp/sources/rx-iterate.hpp b/Rx/v2/src/rxcpp/sources/rx-iterate.hpp index f300b5d14..18c060b41 100644 --- a/Rx/v2/src/rxcpp/sources/rx-iterate.hpp +++ b/Rx/v2/src/rxcpp/sources/rx-iterate.hpp @@ -46,7 +46,7 @@ struct is_iterable template static not_void check(...); - static const bool value = !std::is_same_v(0)), not_void>; + static const bool value = !rxcpp::is_same_v(0)), not_void>; }; template