Skip to content

Commit 907c815

Browse files
authored
Don't repeat class name template arguements (#448)
It prevents mistakes and it simplifies the readability of the code.
1 parent 3789268 commit 907c815

File tree

8 files changed

+62
-64
lines changed

8 files changed

+62
-64
lines changed

include/rfl/Binary.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ struct Binary {
2626

2727
Binary(const Type& _value) : value_(_value) {}
2828

29-
Binary(Binary<T>&& _other) noexcept = default;
29+
Binary(Binary&& _other) noexcept = default;
3030

31-
Binary(const Binary<T>& _other) = default;
31+
Binary(const Binary& _other) = default;
3232

3333
template <class U>
3434
Binary(const Binary<U>& _other) : value_(_other.get()) {}
@@ -77,10 +77,10 @@ struct Binary {
7777
}
7878

7979
/// Assigns the underlying object.
80-
Binary<T>& operator=(const Binary<T>& _other) = default;
80+
Binary& operator=(const Binary<T>& _other) = default;
8181

8282
/// Assigns the underlying object.
83-
Binary<T>& operator=(Binary<T>&& _other) = default;
83+
Binary& operator=(Binary<T>&& _other) = default;
8484

8585
/// Assigns the underlying object.
8686
template <class U>

include/rfl/Box.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,31 @@ class Box {
2929
/// The only way of creating new boxes is
3030
/// Box<T>::make(...).
3131
template <class... Args>
32-
static Box<T, C> make(Args&&... _args) {
33-
return Box<T, C>(std::make_unique<T>(std::forward<Args>(_args)...));
32+
static Box make(Args&&... _args) {
33+
return Box(std::make_unique<T>(std::forward<Args>(_args)...));
3434
}
3535

3636
/// You can generate them from unique_ptrs as well, in which case it will
3737
/// return an Error, if the unique_ptr is not set.
38-
static Result<Box<T, C>> make(std::unique_ptr<T>&& _ptr) {
38+
static Result<Box> make(std::unique_ptr<T>&& _ptr) {
3939
if (!_ptr) {
4040
return error("std::unique_ptr was a nullptr.");
4141
}
42-
return Box<T, C>(std::move(_ptr));
42+
return Box(std::move(_ptr));
4343
}
4444

4545
Box() : ptr_(std::make_unique<T>()) {}
4646

4747
/// Copy constructor if copyable
48-
Box(const Box<T, C>& _other) requires (C == Copyability::COPYABLE)
48+
Box(const Box& _other) requires (C == Copyability::COPYABLE)
4949
{
5050
ptr_ = std::make_unique<T>(*_other);
5151
}
5252

5353
/// Copy constructor if not copyable
54-
Box(const Box<T, C>& _other) requires (C == Copyability::NON_COPYABLE) = delete;
54+
Box(const Box& _other) requires (C == Copyability::NON_COPYABLE) = delete;
5555

56-
Box(Box<T, C>&& _other) = default;
56+
Box(Box&& _other) = default;
5757

5858
template <class U, Copyability C2>
5959
Box(Box<U, C2>&& _other) noexcept
@@ -65,22 +65,22 @@ class Box {
6565
T* get() const { return ptr_.get(); }
6666

6767
/// Copy assignment operator if copyable
68-
Box<T, C>& operator=(const Box<T>& other) requires (C == Copyability::COPYABLE) {
68+
Box& operator=(const Box<T>& other) requires (C == Copyability::COPYABLE) {
6969
if(this != &other) {
7070
ptr_ = std::make_unique<T>(*other);
7171
}
7272
return *this;
7373
}
7474

7575
/// Copy assignment operator if not copyable
76-
Box<T, C>& operator=(const Box<T>& _other) requires (C == Copyability::NON_COPYABLE) = delete;
76+
Box& operator=(const Box& _other) requires (C == Copyability::NON_COPYABLE) = delete;
7777

7878
/// Move assignment operator
79-
Box<T, C>& operator=(Box<T, C>&& _other) noexcept = default;
79+
Box& operator=(Box&& _other) noexcept = default;
8080

8181
/// Move assignment operator
8282
template <class U>
83-
Box<T, C>& operator=(Box<U>&& _other) noexcept {
83+
Box& operator=(Box<U>&& _other) noexcept {
8484
ptr_ = std::forward<std::unique_ptr<U>>(_other.ptr());
8585
return *this;
8686
}

include/rfl/Description.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ struct Description {
3131

3232
Description(Type&& _value) noexcept : value_(std::move(_value)) {}
3333

34-
Description(Description<_description, T>&& _field) noexcept = default;
34+
Description(Description&& _field) noexcept = default;
3535

36-
Description(const Description<_description, Type>& _field) = default;
36+
Description(const Description& _field) = default;
3737

3838
template <class U>
3939
Description(const Description<_description, U>& _field)
@@ -105,12 +105,12 @@ struct Description {
105105
}
106106

107107
/// Assigns the underlying object.
108-
Description<_description, T>& operator=(
109-
const Description<_description, T>& _field) = default;
108+
Description& operator=(
109+
const Description& _field) = default;
110110

111111
/// Assigns the underlying object.
112-
Description<_description, T>& operator=(
113-
Description<_description, T>&& _field) = default;
112+
Description& operator=(
113+
Description&& _field) = default;
114114

115115
/// Assigns the underlying object.
116116
template <class U>

include/rfl/Field.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ struct Field {
2929

3030
Field(Type&& _value) noexcept : value_(std::move(_value)) {}
3131

32-
Field(Field<_name, T>&& _field) noexcept = default;
32+
Field(Field&& _field) noexcept = default;
3333

34-
Field(const Field<_name, T>& _field) = default;
34+
Field(const Field& _field) = default;
3535

3636
template <class U>
3737
Field(const Field<_name, U>& _field) : value_(_field.get()) {}
@@ -104,10 +104,10 @@ struct Field {
104104
}
105105

106106
/// Assigns the underlying object.
107-
Field<_name, T>& operator=(const Field<_name, T>& _field) = default;
107+
Field& operator=(const Field& _field) = default;
108108

109109
/// Assigns the underlying object.
110-
Field<_name, T>& operator=(Field<_name, T>&& _field) = default;
110+
Field& operator=(Field&& _field) = default;
111111

112112
/// Assigns the underlying object.
113113
template <class U>

include/rfl/Flatten.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ struct Flatten {
2121

2222
Flatten(Type&& _value) noexcept : value_(std::forward<Type>(_value)) {}
2323

24-
Flatten(const Flatten<T>& _f) = default;
24+
Flatten(const Flatten& _f) = default;
2525

26-
Flatten(Flatten<T>&& _f) noexcept = default;
26+
Flatten(Flatten&& _f) noexcept = default;
2727

2828
template <class U>
2929
Flatten(const Flatten<U>& _f) : value_(_f.get()) {}
@@ -54,41 +54,41 @@ struct Flatten {
5454
const Type& operator()() const { return value_; }
5555

5656
/// Assigns the underlying object.
57-
Flatten<T>& operator=(const T& _value) {
57+
Flatten& operator=(const T& _value) {
5858
value_ = _value;
5959
return *this;
6060
}
6161

6262
/// Assigns the underlying object.
63-
Flatten<T>& operator=(T&& _value) {
63+
Flatten& operator=(T&& _value) {
6464
value_ = std::forward<Type>(_value);
6565
return *this;
6666
}
6767

6868
/// Assigns the underlying object.
6969
template <class U, typename std::enable_if<std::is_convertible_v<U, Type>,
7070
bool>::type = true>
71-
Flatten<T>& operator=(const U& _value) {
71+
Flatten& operator=(const U& _value) {
7272
value_ = _value;
7373
return *this;
7474
}
7575

7676
/// Assigns the underlying object.
77-
Flatten<T>& operator=(const Flatten<T>& _f) = default;
77+
Flatten& operator=(const Flatten& _f) = default;
7878

7979
/// Assigns the underlying object.
80-
Flatten<T>& operator=(Flatten<T>&& _f) = default;
80+
Flatten& operator=(Flatten&& _f) = default;
8181

8282
/// Assigns the underlying object.
8383
template <class U>
84-
Flatten<T>& operator=(const Flatten<U>& _f) {
84+
Flatten& operator=(const Flatten<U>& _f) {
8585
value_ = _f.get();
8686
return *this;
8787
}
8888

8989
/// Assigns the underlying object.
9090
template <class U>
91-
Flatten<T>& operator=(Flatten<U>&& _f) {
91+
Flatten& operator=(Flatten<U>&& _f) {
9292
value_ = std::forward<U>(_f);
9393
return *this;
9494
}

include/rfl/Tuple.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class Tuple {
4848

4949
Tuple() : Tuple(Types()...) {}
5050

51-
Tuple(const Tuple<Types...>& _other) { copy_from_other(_other, seq_); }
51+
Tuple(const Tuple& _other) { copy_from_other(_other, seq_); }
5252

53-
Tuple(Tuple<Types...>&& _other) noexcept {
53+
Tuple(Tuple&& _other) noexcept {
5454
move_from_other(std::move(_other), seq_);
5555
}
5656

@@ -71,18 +71,18 @@ class Tuple {
7171
}
7272

7373
/// Assigns the underlying object.
74-
Tuple<Types...>& operator=(const Tuple<Types...>& _other) {
74+
Tuple& operator=(const Tuple& _other) {
7575
if (this == &_other) {
7676
return *this;
7777
}
78-
auto temp = Tuple<Types...>(_other);
78+
auto temp = Tuple(_other);
7979
destroy_if_necessary(seq_);
8080
move_from_other(std::move(temp), seq_);
8181
return *this;
8282
}
8383

8484
/// Assigns the underlying object.
85-
Tuple<Types...>& operator=(Tuple<Types...>&& _other) noexcept {
85+
Tuple& operator=(Tuple&& _other) noexcept {
8686
if (this == &_other) {
8787
return *this;
8888
}
@@ -127,7 +127,7 @@ class Tuple {
127127

128128
private:
129129
template <int... _is>
130-
void copy_from_other(const Tuple<Types...>& _other,
130+
void copy_from_other(const Tuple& _other,
131131
std::integer_sequence<int, _is...>) {
132132
const auto copy_one = [this]<int _i>(const auto& _other,
133133
std::integral_constant<int, _i>) {
@@ -161,7 +161,7 @@ class Tuple {
161161
}
162162

163163
template <int... _is>
164-
void move_from_other(Tuple<Types...>&& _other,
164+
void move_from_other(Tuple&& _other,
165165
std::integer_sequence<int, _is...>) {
166166
const auto move_one = [this]<int _i>(auto&& _other,
167167
std::integral_constant<int, _i>) {

include/rfl/Validator.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ struct Validator {
2121
std::conditional_t<sizeof...(Vs) == 0, V, AllOf<V, Vs...>>;
2222

2323
/// Exception-free validation.
24-
static Result<Validator<T, V, Vs...>> from_value(const T& _value) noexcept {
24+
static Result<Validator> from_value(const T& _value) noexcept {
2525
try {
26-
return Validator<T, V, Vs...>(_value);
26+
return Validator(_value);
2727
} catch (std::exception& e) {
2828
return error(e.what());
2929
}
3030
}
3131

3232
Validator() : value_(ValidationType::validate(T()).value()) {}
3333

34-
Validator(Validator<T, V, Vs...>&& _other) noexcept = default;
34+
Validator(Validator&& _other) noexcept = default;
3535

36-
Validator(const Validator<T, V, Vs...>& _other) = default;
36+
Validator(const Validator& _other) = default;
3737

3838
Validator(T&& _value) : value_(ValidationType::validate(_value).value()) {}
3939

@@ -65,11 +65,11 @@ struct Validator {
6565
}
6666

6767
/// Assigns the underlying object.
68-
Validator<T, V, Vs...>& operator=(const Validator<T, V, Vs...>& _other) =
68+
Validator& operator=(const Validator& _other) =
6969
default;
7070

7171
/// Assigns the underlying object.
72-
Validator<T, V, Vs...>& operator=(Validator<T, V, Vs...>&& _other) noexcept =
72+
Validator& operator=(Validator&& _other) noexcept =
7373
default;
7474

7575
/// Assigns the underlying object.
@@ -89,7 +89,7 @@ struct Validator {
8989
}
9090

9191
/// Equality operator other Validators.
92-
bool operator==(const Validator<T, V, Vs...>& _other) const {
92+
bool operator==(const Validator& _other) const {
9393
return value() == _other.value();
9494
}
9595

0 commit comments

Comments
 (0)