Skip to content

Commit 7f97aa9

Browse files
replace C-style pointer cast type deduction by 'std::declval<>()' (#572)
* updated Catch2 to v2.13.8 (216713a) ... previous version does not compile on more modern Linux OSes * replaced C-style pointer cast type deduction by 'std::declval<>()' addresses issue #570 * replaced C-style typedef type aliasing by 'using type = ' see also [C++ Core Guidelines - T.43]( http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using) N.B. this should make later refactoring (and possible introduction of 'concepts') a bit easier ... * replaced 'std::is_same<...>::value' by 'std::is_same_v<...>' * replaced 'std::conditional<...>::type' by 'std::conditional_t<...>'
1 parent 6770aea commit 7f97aa9

File tree

92 files changed

+890
-921
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+890
-921
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ using all_invalid_t = typename all_invalid<AN...>::type;
4242
template<class T, class Predicate>
4343
struct all
4444
{
45-
typedef rxu::decay_t<T> source_value_type;
46-
typedef rxu::decay_t<Predicate> test_type;
45+
using source_value_type = rxu::decay_t<T>;
46+
using test_type = rxu::decay_t<Predicate>;
4747
test_type test;
4848

49-
typedef bool value_type;
49+
using value_type = bool;
5050

5151
all(test_type t)
5252
: test(std::move(t))
@@ -56,10 +56,10 @@ struct all
5656
template<class Subscriber>
5757
struct all_observer
5858
{
59-
typedef all_observer<Subscriber> this_type;
60-
typedef source_value_type value_type;
61-
typedef rxu::decay_t<Subscriber> dest_type;
62-
typedef observer<value_type, this_type> observer_type;
59+
using this_type = all_observer<Subscriber>;
60+
using value_type = source_value_type;
61+
using dest_type = rxu::decay_t<Subscriber>;
62+
using observer_type = observer<value_type, this_type>;
6363
dest_type dest;
6464
test_type test;
6565
mutable bool done;

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ struct amb
6464
//static_assert(is_observable<Observable>::value, "amb requires an observable");
6565
//static_assert(is_observable<T>::value, "amb requires an observable that contains observables");
6666

67-
typedef amb<T, Observable, Coordination> this_type;
67+
using this_type = amb<T, Observable, Coordination>;
6868

69-
typedef rxu::decay_t<T> source_value_type;
70-
typedef rxu::decay_t<Observable> source_type;
69+
using source_value_type = rxu::decay_t<T>;
70+
using source_type = rxu::decay_t<Observable>;
7171

72-
typedef typename source_type::source_operator_type source_operator_type;
73-
typedef typename source_value_type::value_type value_type;
72+
using source_operator_type = typename source_type::source_operator_type;
73+
using value_type = typename source_value_type::value_type;
7474

75-
typedef rxu::decay_t<Coordination> coordination_type;
76-
typedef typename coordination_type::coordinator_type coordinator_type;
75+
using coordination_type = rxu::decay_t<Coordination>;
76+
using coordinator_type = typename coordination_type::coordinator_type;
7777

7878
struct values
7979
{
@@ -96,7 +96,7 @@ struct amb
9696
void on_subscribe(Subscriber scbr) const {
9797
static_assert(is_subscriber<Subscriber>::value, "subscribe must be passed a subscriber");
9898

99-
typedef Subscriber output_type;
99+
using output_type = Subscriber;
100100

101101
struct amb_state_type
102102
: public std::enable_shared_from_this<amb_state_type>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ using any_invalid_t = typename any_invalid<AN...>::type;
5050
template<class T, class Predicate>
5151
struct any
5252
{
53-
typedef rxu::decay_t<T> source_value_type;
54-
typedef bool value_type;
55-
typedef rxu::decay_t<Predicate> test_type;
53+
using source_value_type = rxu::decay_t<T>;
54+
using value_type = bool;
55+
using test_type = rxu::decay_t<Predicate>;
5656
test_type test;
5757

5858
any(test_type t)
@@ -63,10 +63,10 @@ struct any
6363
template<class Subscriber>
6464
struct any_observer
6565
{
66-
typedef any_observer<Subscriber> this_type;
67-
typedef source_value_type value_type;
68-
typedef rxu::decay_t<Subscriber> dest_type;
69-
typedef observer<value_type, this_type> observer_type;
66+
using this_type = any_observer<Subscriber>;
67+
using value_type = source_value_type;
68+
using dest_type = rxu::decay_t<Subscriber>;
69+
using observer_type = observer<value_type, this_type>;
7070
dest_type dest;
7171
test_type test;
7272
mutable bool done;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ using buffer_count_invalid_t = typename buffer_count_invalid<AN...>::type;
4646
template<class T>
4747
struct buffer_count
4848
{
49-
typedef rxu::decay_t<T> source_value_type;
50-
typedef std::vector<source_value_type> value_type;
49+
using source_value_type = rxu::decay_t<T>;
50+
using value_type = std::vector<source_value_type>;
5151

5252
struct buffer_count_values
5353
{
@@ -70,10 +70,10 @@ struct buffer_count
7070
template<class Subscriber>
7171
struct buffer_count_observer : public buffer_count_values
7272
{
73-
typedef buffer_count_observer<Subscriber> this_type;
74-
typedef std::vector<T> value_type;
75-
typedef rxu::decay_t<Subscriber> dest_type;
76-
typedef observer<value_type, this_type> observer_type;
73+
using this_type = buffer_count_observer<Subscriber>;
74+
using value_type = std::vector<T>;
75+
using dest_type = rxu::decay_t<Subscriber>;
76+
using observer_type = observer<value_type, this_type>;
7777
dest_type dest;
7878
mutable int cursor;
7979
mutable std::deque<value_type> chunks;

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ using buffer_with_time_invalid_t = typename buffer_with_time_invalid<AN...>::typ
6666
template<class T, class Duration, class Coordination>
6767
struct buffer_with_time
6868
{
69-
typedef rxu::decay_t<T> source_value_type;
70-
typedef std::vector<source_value_type> value_type;
71-
typedef rxu::decay_t<Coordination> coordination_type;
72-
typedef typename coordination_type::coordinator_type coordinator_type;
73-
typedef rxu::decay_t<Duration> duration_type;
69+
using source_value_type = rxu::decay_t<T>;
70+
using value_type = std::vector<source_value_type>;
71+
using coordination_type = rxu::decay_t<Coordination>;
72+
using coordinator_type = typename coordination_type::coordinator_type;
73+
using duration_type = rxu::decay_t<Duration>;
7474

7575
struct buffer_with_time_values
7676
{
@@ -94,10 +94,10 @@ struct buffer_with_time
9494
template<class Subscriber>
9595
struct buffer_with_time_observer
9696
{
97-
typedef buffer_with_time_observer<Subscriber> this_type;
98-
typedef std::vector<T> value_type;
99-
typedef rxu::decay_t<Subscriber> dest_type;
100-
typedef observer<value_type, this_type> observer_type;
97+
using this_type = buffer_with_time_observer<Subscriber>;
98+
using value_type = std::vector<T>;
99+
using dest_type = rxu::decay_t<Subscriber>;
100+
using observer_type = observer<value_type, this_type>;
101101

102102
struct buffer_with_time_subscriber_values : public buffer_with_time_values
103103
{

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ using buffer_with_time_or_count_invalid_t = typename buffer_with_time_or_count_i
4848
template<class T, class Duration, class Coordination>
4949
struct buffer_with_time_or_count
5050
{
51-
typedef rxu::decay_t<T> source_value_type;
52-
typedef std::vector<source_value_type> value_type;
53-
typedef rxu::decay_t<Coordination> coordination_type;
54-
typedef typename coordination_type::coordinator_type coordinator_type;
55-
typedef rxu::decay_t<Duration> duration_type;
51+
using source_value_type = rxu::decay_t<T>;
52+
using value_type = std::vector<source_value_type>;
53+
using coordination_type = rxu::decay_t<Coordination>;
54+
using coordinator_type = typename coordination_type::coordinator_type;
55+
using duration_type = rxu::decay_t<Duration>;
5656

5757
struct buffer_with_time_or_count_values
5858
{
@@ -76,10 +76,10 @@ struct buffer_with_time_or_count
7676
template<class Subscriber>
7777
struct buffer_with_time_or_count_observer
7878
{
79-
typedef buffer_with_time_or_count_observer<Subscriber> this_type;
80-
typedef std::vector<T> value_type;
81-
typedef rxu::decay_t<Subscriber> dest_type;
82-
typedef observer<value_type, this_type> observer_type;
79+
using this_type = buffer_with_time_or_count_observer<Subscriber>;
80+
using value_type = std::vector<T>;
81+
using dest_type = rxu::decay_t<Subscriber>;
82+
using observer_type = observer<value_type, this_type>;
8383

8484
struct buffer_with_time_or_count_subscriber_values : public buffer_with_time_or_count_values
8585
{
@@ -99,7 +99,8 @@ struct buffer_with_time_or_count
9999
mutable int chunk_id;
100100
mutable value_type chunk;
101101
};
102-
typedef std::shared_ptr<buffer_with_time_or_count_subscriber_values> state_type;
102+
103+
using state_type = std::shared_ptr<buffer_with_time_or_count_subscriber_values>;
103104
state_type state;
104105

105106
buffer_with_time_or_count_observer(composite_subscription cs, dest_type d, buffer_with_time_or_count_values v, coordinator_type c)

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ using combine_latest_invalid_t = typename combine_latest_invalid<AN...>::type;
5858

5959
template<class Selector, class... ObservableN>
6060
struct is_combine_latest_selector_check {
61-
typedef rxu::decay_t<Selector> selector_type;
61+
using selector_type = rxu::decay_t<Selector>;
6262

6363
struct tag_not_valid;
6464
template<class CS, class... CON>
65-
static auto check(int) -> decltype((*(CS*)nullptr)((*(typename CON::value_type*)nullptr)...));
65+
static auto check(int) -> decltype(std::declval<CS>()((std::declval<typename CON::value_type>())...));
6666
template<class CS, class... CON>
6767
static tag_not_valid check(...);
6868

6969
using type = decltype(check<selector_type, rxu::decay_t<ObservableN>...>(0));
7070

71-
static const bool value = !std::is_same<type, tag_not_valid>::value;
71+
static const bool value = !std::is_same_v<type, tag_not_valid>;
7272
};
7373

7474
template<class Selector, class... ObservableN>
@@ -77,10 +77,10 @@ struct invalid_combine_latest_selector {
7777
};
7878

7979
template<class Selector, class... ObservableN>
80-
struct is_combine_latest_selector : public std::conditional<
80+
struct is_combine_latest_selector : public std::conditional_t<
8181
is_combine_latest_selector_check<Selector, ObservableN...>::value,
8282
is_combine_latest_selector_check<Selector, ObservableN...>,
83-
invalid_combine_latest_selector<Selector, ObservableN...>>::type {
83+
invalid_combine_latest_selector<Selector, ObservableN...>> {
8484
};
8585

8686
template<class Selector, class... ON>
@@ -89,29 +89,29 @@ using result_combine_latest_selector_t = typename is_combine_latest_selector<Sel
8989
template<class Coordination, class Selector, class... ObservableN>
9090
struct combine_latest_traits {
9191

92-
typedef std::tuple<ObservableN...> tuple_source_type;
93-
typedef std::tuple<rxu::detail::maybe<typename ObservableN::value_type>...> tuple_source_value_type;
92+
using tuple_source_type = std::tuple<ObservableN...>;
93+
using tuple_source_value_type = std::tuple<rxu::detail::maybe < typename ObservableN::value_type>...>;
9494

95-
typedef rxu::decay_t<Selector> selector_type;
96-
typedef rxu::decay_t<Coordination> coordination_type;
95+
using selector_type = rxu::decay_t<Selector>;
96+
using coordination_type = rxu::decay_t<Coordination>;
9797

98-
typedef typename is_combine_latest_selector<selector_type, ObservableN...>::type value_type;
98+
using value_type = typename is_combine_latest_selector<selector_type, ObservableN...>::type;
9999
};
100100

101101
template<class Coordination, class Selector, class... ObservableN>
102102
struct combine_latest : public operator_base<rxu::value_type_t<combine_latest_traits<Coordination, Selector, ObservableN...>>>
103103
{
104-
typedef combine_latest<Coordination, Selector, ObservableN...> this_type;
104+
using this_type = combine_latest<Coordination, Selector, ObservableN...>;
105105

106-
typedef combine_latest_traits<Coordination, Selector, ObservableN...> traits;
106+
using traits = combine_latest_traits<Coordination, Selector, ObservableN...>;
107107

108-
typedef typename traits::tuple_source_type tuple_source_type;
109-
typedef typename traits::tuple_source_value_type tuple_source_value_type;
108+
using tuple_source_type = typename traits::tuple_source_type;
109+
using tuple_source_value_type = typename traits::tuple_source_value_type;
110110

111-
typedef typename traits::selector_type selector_type;
111+
using selector_type = typename traits::selector_type;
112112

113-
typedef typename traits::coordination_type coordination_type;
114-
typedef typename coordination_type::coordinator_type coordinator_type;
113+
using coordination_type = typename traits::coordination_type;
114+
using coordinator_type = typename coordination_type::coordinator_type;
115115

116116
struct values
117117
{
@@ -135,7 +135,7 @@ struct combine_latest : public operator_base<rxu::value_type_t<combine_latest_tr
135135
template<int Index, class State>
136136
void subscribe_one(std::shared_ptr<State> state) const {
137137

138-
typedef typename std::tuple_element<Index, tuple_source_type>::type::value_type source_value_type;
138+
using source_value_type = typename std::tuple_element<Index, tuple_source_type>::type::value_type;
139139

140140
composite_subscription innercs;
141141

@@ -200,7 +200,7 @@ struct combine_latest : public operator_base<rxu::value_type_t<combine_latest_tr
200200
void on_subscribe(Subscriber scbr) const {
201201
static_assert(is_subscriber<Subscriber>::value, "subscribe must be passed a subscriber");
202202

203-
typedef Subscriber output_type;
203+
using output_type = Subscriber;
204204

205205
struct combine_latest_state_type
206206
: public std::enable_shared_from_this<combine_latest_state_type>

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ template<class T, class Observable, class Coordination>
6363
struct concat
6464
: public operator_base<rxu::value_type_t<rxu::decay_t<T>>>
6565
{
66-
typedef concat<T, Observable, Coordination> this_type;
66+
using this_type = concat<T, Observable, Coordination>;
6767

68-
typedef rxu::decay_t<T> source_value_type;
69-
typedef rxu::decay_t<Observable> source_type;
70-
typedef rxu::decay_t<Coordination> coordination_type;
68+
using source_value_type = rxu::decay_t<T>;
69+
using source_type = rxu::decay_t<Observable>;
70+
using coordination_type = rxu::decay_t<Coordination>;
7171

72-
typedef typename coordination_type::coordinator_type coordinator_type;
72+
using coordinator_type = typename coordination_type::coordinator_type;
7373

74-
typedef typename source_type::source_operator_type source_operator_type;
75-
typedef source_value_type collection_type;
76-
typedef typename collection_type::value_type value_type;
74+
using source_operator_type = typename source_type::source_operator_type;
75+
using collection_type = source_value_type;
76+
using value_type = typename collection_type::value_type;
7777

7878
struct values
7979
{
@@ -96,7 +96,7 @@ struct concat
9696
void on_subscribe(Subscriber scbr) const {
9797
static_assert(is_subscriber<Subscriber>::value, "subscribe must be passed a subscriber");
9898

99-
typedef Subscriber output_type;
99+
using output_type = Subscriber;
100100

101101
struct concat_state_type
102102
: public std::enable_shared_from_this<concat_state_type>

0 commit comments

Comments
 (0)