From 2184a7d0920fbf6208edcca4c82bd273ec37749a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 26 Dec 2019 16:25:42 +0100 Subject: new_type: move decay to the constructor base --- include/newtype/new_type.hpp | 34 +++++++++++++++++++++------------- 1 file 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; }; @@ -86,14 +102,6 @@ namespace nt auto constexpr static derivations = DerivationClause; 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 * @@ -103,7 +111,7 @@ namespace nt template * = nullptr> constexpr operator base_type() const noexcept(std::is_nothrow_copy_constructible_v) { - return decay(); + return this->decay(); } /** @@ -115,10 +123,10 @@ namespace nt template * = nullptr> explicit constexpr operator base_type() const noexcept(std::is_nothrow_copy_constructible_v) { - return decay(); + return this->decay(); } }; } // namespace nt -#endif \ No newline at end of file +#endif -- cgit v1.2.3