diff --git a/include/rfl/Binary.hpp b/include/rfl/Binary.hpp index 1b0aee2c..02aa0471 100644 --- a/include/rfl/Binary.hpp +++ b/include/rfl/Binary.hpp @@ -26,9 +26,9 @@ struct Binary { Binary(const Type& _value) : value_(_value) {} - Binary(Binary&& _other) noexcept = default; + Binary(Binary&& _other) noexcept = default; - Binary(const Binary& _other) = default; + Binary(const Binary& _other) = default; template Binary(const Binary& _other) : value_(_other.get()) {} @@ -77,10 +77,10 @@ struct Binary { } /// Assigns the underlying object. - Binary& operator=(const Binary& _other) = default; + Binary& operator=(const Binary& _other) = default; /// Assigns the underlying object. - Binary& operator=(Binary&& _other) = default; + Binary& operator=(Binary&& _other) = default; /// Assigns the underlying object. template diff --git a/include/rfl/Box.hpp b/include/rfl/Box.hpp index b8c90340..686c34b1 100644 --- a/include/rfl/Box.hpp +++ b/include/rfl/Box.hpp @@ -29,31 +29,31 @@ class Box { /// The only way of creating new boxes is /// Box::make(...). template - static Box make(Args&&... _args) { - return Box(std::make_unique(std::forward(_args)...)); + static Box make(Args&&... _args) { + return Box(std::make_unique(std::forward(_args)...)); } /// You can generate them from unique_ptrs as well, in which case it will /// return an Error, if the unique_ptr is not set. - static Result> make(std::unique_ptr&& _ptr) { + static Result make(std::unique_ptr&& _ptr) { if (!_ptr) { return error("std::unique_ptr was a nullptr."); } - return Box(std::move(_ptr)); + return Box(std::move(_ptr)); } Box() : ptr_(std::make_unique()) {} /// Copy constructor if copyable - Box(const Box& _other) requires (C == Copyability::COPYABLE) + Box(const Box& _other) requires (C == Copyability::COPYABLE) { ptr_ = std::make_unique(*_other); } /// Copy constructor if not copyable - Box(const Box& _other) requires (C == Copyability::NON_COPYABLE) = delete; + Box(const Box& _other) requires (C == Copyability::NON_COPYABLE) = delete; - Box(Box&& _other) = default; + Box(Box&& _other) = default; template Box(Box&& _other) noexcept @@ -65,7 +65,7 @@ class Box { T* get() const { return ptr_.get(); } /// Copy assignment operator if copyable - Box& operator=(const Box& other) requires (C == Copyability::COPYABLE) { + Box& operator=(const Box& other) requires (C == Copyability::COPYABLE) { if(this != &other) { ptr_ = std::make_unique(*other); } @@ -73,14 +73,14 @@ class Box { } /// Copy assignment operator if not copyable - Box& operator=(const Box& _other) requires (C == Copyability::NON_COPYABLE) = delete; + Box& operator=(const Box& _other) requires (C == Copyability::NON_COPYABLE) = delete; /// Move assignment operator - Box& operator=(Box&& _other) noexcept = default; + Box& operator=(Box&& _other) noexcept = default; /// Move assignment operator template - Box& operator=(Box&& _other) noexcept { + Box& operator=(Box&& _other) noexcept { ptr_ = std::forward>(_other.ptr()); return *this; } diff --git a/include/rfl/Description.hpp b/include/rfl/Description.hpp index ef3e8344..46692b7d 100644 --- a/include/rfl/Description.hpp +++ b/include/rfl/Description.hpp @@ -31,9 +31,9 @@ struct Description { Description(Type&& _value) noexcept : value_(std::move(_value)) {} - Description(Description<_description, T>&& _field) noexcept = default; + Description(Description&& _field) noexcept = default; - Description(const Description<_description, Type>& _field) = default; + Description(const Description& _field) = default; template Description(const Description<_description, U>& _field) @@ -105,12 +105,12 @@ struct Description { } /// Assigns the underlying object. - Description<_description, T>& operator=( - const Description<_description, T>& _field) = default; + Description& operator=( + const Description& _field) = default; /// Assigns the underlying object. - Description<_description, T>& operator=( - Description<_description, T>&& _field) = default; + Description& operator=( + Description&& _field) = default; /// Assigns the underlying object. template diff --git a/include/rfl/Field.hpp b/include/rfl/Field.hpp index fa576639..24035114 100644 --- a/include/rfl/Field.hpp +++ b/include/rfl/Field.hpp @@ -29,9 +29,9 @@ struct Field { Field(Type&& _value) noexcept : value_(std::move(_value)) {} - Field(Field<_name, T>&& _field) noexcept = default; + Field(Field&& _field) noexcept = default; - Field(const Field<_name, T>& _field) = default; + Field(const Field& _field) = default; template Field(const Field<_name, U>& _field) : value_(_field.get()) {} @@ -104,10 +104,10 @@ struct Field { } /// Assigns the underlying object. - Field<_name, T>& operator=(const Field<_name, T>& _field) = default; + Field& operator=(const Field& _field) = default; /// Assigns the underlying object. - Field<_name, T>& operator=(Field<_name, T>&& _field) = default; + Field& operator=(Field&& _field) = default; /// Assigns the underlying object. template diff --git a/include/rfl/Flatten.hpp b/include/rfl/Flatten.hpp index 04ea6f38..b7a7726f 100644 --- a/include/rfl/Flatten.hpp +++ b/include/rfl/Flatten.hpp @@ -21,9 +21,9 @@ struct Flatten { Flatten(Type&& _value) noexcept : value_(std::forward(_value)) {} - Flatten(const Flatten& _f) = default; + Flatten(const Flatten& _f) = default; - Flatten(Flatten&& _f) noexcept = default; + Flatten(Flatten&& _f) noexcept = default; template Flatten(const Flatten& _f) : value_(_f.get()) {} @@ -54,13 +54,13 @@ struct Flatten { const Type& operator()() const { return value_; } /// Assigns the underlying object. - Flatten& operator=(const T& _value) { + Flatten& operator=(const T& _value) { value_ = _value; return *this; } /// Assigns the underlying object. - Flatten& operator=(T&& _value) { + Flatten& operator=(T&& _value) { value_ = std::forward(_value); return *this; } @@ -68,27 +68,27 @@ struct Flatten { /// Assigns the underlying object. template , bool>::type = true> - Flatten& operator=(const U& _value) { + Flatten& operator=(const U& _value) { value_ = _value; return *this; } /// Assigns the underlying object. - Flatten& operator=(const Flatten& _f) = default; + Flatten& operator=(const Flatten& _f) = default; /// Assigns the underlying object. - Flatten& operator=(Flatten&& _f) = default; + Flatten& operator=(Flatten&& _f) = default; /// Assigns the underlying object. template - Flatten& operator=(const Flatten& _f) { + Flatten& operator=(const Flatten& _f) { value_ = _f.get(); return *this; } /// Assigns the underlying object. template - Flatten& operator=(Flatten&& _f) { + Flatten& operator=(Flatten&& _f) { value_ = std::forward(_f); return *this; } diff --git a/include/rfl/Tuple.hpp b/include/rfl/Tuple.hpp index a2cffe80..828f6659 100644 --- a/include/rfl/Tuple.hpp +++ b/include/rfl/Tuple.hpp @@ -48,9 +48,9 @@ class Tuple { Tuple() : Tuple(Types()...) {} - Tuple(const Tuple& _other) { copy_from_other(_other, seq_); } + Tuple(const Tuple& _other) { copy_from_other(_other, seq_); } - Tuple(Tuple&& _other) noexcept { + Tuple(Tuple&& _other) noexcept { move_from_other(std::move(_other), seq_); } @@ -71,18 +71,18 @@ class Tuple { } /// Assigns the underlying object. - Tuple& operator=(const Tuple& _other) { + Tuple& operator=(const Tuple& _other) { if (this == &_other) { return *this; } - auto temp = Tuple(_other); + auto temp = Tuple(_other); destroy_if_necessary(seq_); move_from_other(std::move(temp), seq_); return *this; } /// Assigns the underlying object. - Tuple& operator=(Tuple&& _other) noexcept { + Tuple& operator=(Tuple&& _other) noexcept { if (this == &_other) { return *this; } @@ -127,7 +127,7 @@ class Tuple { private: template - void copy_from_other(const Tuple& _other, + void copy_from_other(const Tuple& _other, std::integer_sequence) { const auto copy_one = [this](const auto& _other, std::integral_constant) { @@ -161,7 +161,7 @@ class Tuple { } template - void move_from_other(Tuple&& _other, + void move_from_other(Tuple&& _other, std::integer_sequence) { const auto move_one = [this](auto&& _other, std::integral_constant) { diff --git a/include/rfl/Validator.hpp b/include/rfl/Validator.hpp index 0673c9e3..7bf1fbc7 100644 --- a/include/rfl/Validator.hpp +++ b/include/rfl/Validator.hpp @@ -21,9 +21,9 @@ struct Validator { std::conditional_t>; /// Exception-free validation. - static Result> from_value(const T& _value) noexcept { + static Result from_value(const T& _value) noexcept { try { - return Validator(_value); + return Validator(_value); } catch (std::exception& e) { return error(e.what()); } @@ -31,9 +31,9 @@ struct Validator { Validator() : value_(ValidationType::validate(T()).value()) {} - Validator(Validator&& _other) noexcept = default; + Validator(Validator&& _other) noexcept = default; - Validator(const Validator& _other) = default; + Validator(const Validator& _other) = default; Validator(T&& _value) : value_(ValidationType::validate(_value).value()) {} @@ -65,11 +65,11 @@ struct Validator { } /// Assigns the underlying object. - Validator& operator=(const Validator& _other) = + Validator& operator=(const Validator& _other) = default; /// Assigns the underlying object. - Validator& operator=(Validator&& _other) noexcept = + Validator& operator=(Validator&& _other) noexcept = default; /// Assigns the underlying object. @@ -89,7 +89,7 @@ struct Validator { } /// Equality operator other Validators. - bool operator==(const Validator& _other) const { + bool operator==(const Validator& _other) const { return value() == _other.value(); } diff --git a/include/rfl/Variant.hpp b/include/rfl/Variant.hpp index 4fe609cb..1e3fb6c9 100644 --- a/include/rfl/Variant.hpp +++ b/include/rfl/Variant.hpp @@ -11,10 +11,10 @@ #include "internal/element_index.hpp" #include "internal/nth_element_t.hpp" +#include "internal/ptr_cast.hpp" #include "internal/variant/find_max_size.hpp" #include "internal/variant/is_alternative_type.hpp" #include "internal/variant/result_t.hpp" -#include "internal/ptr_cast.hpp" namespace rfl { @@ -49,12 +49,12 @@ class Variant { move_from_type(FirstAlternative()); } - Variant(const Variant& _other) + Variant(const Variant& _other) : index_(IndexType()), data_(DataType()) { copy_from_other(_other); } - Variant(Variant&& _other) noexcept + Variant(Variant&& _other) noexcept : index_(IndexType()), data_(DataType()) { move_from_other(std::move(_other)); } @@ -101,8 +101,8 @@ class Variant { typename std::enable_if(), bool>::type = true> - Variant& operator=(const T& _t) { - auto temp = Variant(_t); + Variant& operator=(const T& _t) { + auto temp = Variant(_t); destroy_if_necessary(); move_from_other(std::move(temp)); return *this; @@ -113,27 +113,25 @@ class Variant { typename std::enable_if(), bool>::type = true> - Variant& operator=(T&& _t) noexcept { + Variant& operator=(T&& _t) noexcept { destroy_if_necessary(); move_from_type(std::forward(_t)); return *this; } /// Assigns the underlying object. - Variant& operator=( - const Variant& _other) { + Variant& operator=(const Variant& _other) { if (this == &_other) { return *this; } - auto temp = Variant(_other); + auto temp = Variant(_other); destroy_if_necessary(); move_from_other(std::move(temp)); return *this; } /// Assigns the underlying object. - Variant& operator=( - Variant&& _other) noexcept { + Variant& operator=(Variant&& _other) noexcept { if (this == &_other) { return *this; } @@ -143,11 +141,11 @@ class Variant { } /// Swaps the content with the other variant. - void swap(Variant& _other) noexcept { + void swap(Variant& _other) noexcept { if (this == &_other) { return; } - auto temp = Variant(std::move(*this)); + auto temp = Variant(std::move(*this)); move_from_other(std::move(_other)); _other = std::move(temp); } @@ -193,7 +191,7 @@ class Variant { } private: - void copy_from_other(const Variant& _other) { + void copy_from_other(const Variant& _other) { const auto copy_one = [this](const auto& _t) { this->copy_from_type(_t); }; _other.visit(copy_one); } @@ -396,11 +394,11 @@ class Variant { return *internal::ptr_cast(data_.data()); } - void move_from_other(Variant&& _other) noexcept { + void move_from_other(Variant&& _other) noexcept { const auto move_one = [this](auto&& _t) { this->move_from_type(std::forward>(_t)); }; - std::forward>(_other).visit(move_one); + std::move(_other).visit(move_one); } template