diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2019-12-26 16:25:42 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2019-12-26 16:25:42 +0100 |
| commit | 2184a7d0920fbf6208edcca4c82bd273ec37749a (patch) | |
| tree | 7d6520a196617fdb163b1786680b5c0dff88fc73 | |
| parent | 322c94ad33789d6eaa6a260a9028e5c5476df92f (diff) | |
| download | newtype-2184a7d0920fbf6208edcca4c82bd273ec37749a.tar.xz newtype-2184a7d0920fbf6208edcca4c82bd273ec37749a.zip | |
new_type: move decay to the constructor base
| -rw-r--r-- | include/newtype/new_type.hpp | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/include/newtype/new_type.hpp b/include/newtype/new_type.hpp index 9c1074c..4d8ad66 100644 --- a/include/newtype/new_type.hpp +++ b/include/newtype/new_type.hpp @@ -36,7 +36,15 @@ namespace nt { } - protected: + /** + * Retrieve the base type value contained in this @p new_type + */ + auto constexpr decay() const noexcept -> BaseType + { + return m_value; + } + + private: BaseType m_value{}; }; @@ -64,7 +72,15 @@ namespace nt { } - protected: + /** + * Retrieve the base type value contained in this @p new_type + */ + auto constexpr decay() const noexcept -> BaseType + { + return m_value; + } + + private: BaseType m_value; }; @@ -87,14 +103,6 @@ namespace nt public: /** - * Retrieve the base type value contained in this @p new_type - */ - auto constexpr decay() const noexcept -> BaseType - { - return this->m_value; - } - - /** * Convert this instance into the equivalent base type value * * @note This overload participates only in overload resolution if the derication clause of this @p new_type contains @@ -103,7 +111,7 @@ namespace nt template<typename NewType = new_type, std::enable_if_t<NewType::derivations(nt::ImplicitConversion)> * = nullptr> constexpr operator base_type() const noexcept(std::is_nothrow_copy_constructible_v<base_type>) { - return decay(); + return this->decay(); } /** @@ -115,10 +123,10 @@ namespace nt template<typename NewType = new_type, std::enable_if_t<!NewType::derivations(nt::ImplicitConversion)> * = nullptr> explicit constexpr operator base_type() const noexcept(std::is_nothrow_copy_constructible_v<base_type>) { - return decay(); + return this->decay(); } }; } // namespace nt -#endif
\ No newline at end of file +#endif |
