From 51fa037d4d31ac006001a6c1965e9ad506056d5a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sun, 29 Dec 2019 16:56:39 +0100 Subject: new_type: remove superfluous constructor --- include/newtype/impl/new_type_storage.hpp | 38 +++++++++---------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/include/newtype/impl/new_type_storage.hpp b/include/newtype/impl/new_type_storage.hpp index 414eff4..5f64771 100644 --- a/include/newtype/impl/new_type_storage.hpp +++ b/include/newtype/impl/new_type_storage.hpp @@ -14,9 +14,13 @@ namespace nt::impl { } - template - constexpr explicit new_type_storage(ArgumentType && value) noexcept(std::is_nothrow_constructible_v) - : m_value{std::forward(value)} + constexpr new_type_storage(BaseType const & value) + : m_value{value} + { + } + + constexpr new_type_storage(BaseType && value) + : m_value{std::move(value)} { } @@ -26,37 +30,15 @@ namespace nt::impl template> struct new_type_constructor : new_type_storage { - using super = new_type_storage; - using super::super; - - constexpr new_type_constructor(BaseType const & value) - : super{value} - { - } - - constexpr new_type_constructor(BaseType && value) - : super{std::move(value)} - { - } + using new_type_storage::new_type_storage; }; template struct new_type_constructor : new_type_storage { - using super = new_type_storage; - using super::super; + using new_type_storage::new_type_storage; constexpr new_type_constructor() = delete; - - constexpr new_type_constructor(BaseType const & value) - : super{value} - { - } - - constexpr new_type_constructor(BaseType && value) - : super{std::move(value)} - { - } }; template> @@ -77,6 +59,7 @@ namespace nt::impl constexpr new_type_copy_constructor(new_type_copy_constructor const &) = delete; constexpr new_type_copy_constructor(new_type_copy_constructor &&) = default; + constexpr new_type_copy_constructor(BaseType const &) = delete; auto constexpr operator=(new_type_copy_constructor &) -> new_type_copy_constructor & = default; auto constexpr operator=(new_type_copy_constructor &&) -> new_type_copy_constructor & = default; }; @@ -99,6 +82,7 @@ namespace nt::impl constexpr new_type_move_constructor(new_type_move_constructor const &) = default; constexpr new_type_move_constructor(new_type_move_constructor &&) = delete; + constexpr new_type_move_constructor(BaseType &&) = delete; auto constexpr operator=(new_type_move_constructor &) -> new_type_move_constructor & = default; auto constexpr operator=(new_type_move_constructor &&) -> new_type_move_constructor & = default; }; -- cgit v1.2.3