diff --git a/sprout/tuple/tuple.hpp b/sprout/tuple/tuple.hpp index d2bd9bf8..4b26406d 100644 --- a/sprout/tuple/tuple.hpp +++ b/sprout/tuple/tuple.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace sprout { namespace tuples { @@ -71,6 +71,24 @@ namespace sprout { void swap(tuple_impl&) SPROUT_NOEXCEPT {} public: tuple_impl() = default; + template + SPROUT_CONSTEXPR explicit tuple_impl(UTypes&&... args) SPROUT_NOEXCEPT {} + SPROUT_CONSTEXPR tuple_impl(tuple_impl const&) = default; + SPROUT_CONSTEXPR tuple_impl(tuple_impl&&) = default; + template + SPROUT_CONSTEXPR tuple_impl(tuple_impl const& t) SPROUT_NOEXCEPT {} + template + SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t) SPROUT_NOEXCEPT {} + tuple_impl& operator=(tuple_impl const&) = default; + tuple_impl& operator=(tuple_impl&& t) = default; + template + tuple_impl& operator=(sprout::tuples::detail::tuple_impl const&) SPROUT_NOEXCEPT { + return *this; + } + template + tuple_impl& operator=(sprout::tuples::detail::tuple_impl&&) SPROUT_NOEXCEPT { + return *this; + } }; template class tuple_impl @@ -87,7 +105,7 @@ namespace sprout { static SPROUT_CONSTEXPR Head& head(tuple_impl& t) SPROUT_NOEXCEPT { return base_type::head(t); } - static SPROUT_CONSTEXPR const Head& head(tuple_impl const& t) SPROUT_NOEXCEPT { + static SPROUT_CONSTEXPR Head const& head(tuple_impl const& t) SPROUT_NOEXCEPT { return base_type::head(t); } static SPROUT_CONSTEXPR inherited_type& tail(tuple_impl& t) SPROUT_NOEXCEPT { @@ -115,7 +133,7 @@ namespace sprout { : inherited_type(tail...) , base_type(h) {} - template::type> + template SPROUT_CONSTEXPR explicit tuple_impl(UHead&& h, UTail&&... tail) : inherited_type(sprout::forward(tail)...) , base_type(sprout::forward(h)) @@ -123,7 +141,7 @@ namespace sprout { SPROUT_CONSTEXPR tuple_impl(tuple_impl const&) = default; SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t) SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_constructible::value && std::is_nothrow_move_constructible::value) - : inherited_type(std::move(tail(t))) + : inherited_type(sprout::move(tail(t))) , base_type(sprout::forward(head(t))) {} template @@ -133,9 +151,17 @@ namespace sprout { {} template SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t) - : inherited_type(std::move(sprout::tuples::detail::tuple_impl::tail(t))) + : inherited_type(sprout::move(sprout::tuples::detail::tuple_impl::tail(t))) , base_type(sprout::forward(sprout::tuples::detail::tuple_impl::head(t))) {} + SPROUT_CONSTEXPR tuple_impl(tuple_impl const& t) + : inherited_type() + , base_type() + {} + SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t) + : inherited_type() + , base_type() + {} tuple_impl& operator=(tuple_impl const& t) { head(*this) = head(t); tail(*this) = tail(t); @@ -145,7 +171,7 @@ namespace sprout { SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) { head(*this) = sprout::forward(head(t)); - tail(*this) = std::move(tail(t)); + tail(*this) = sprout::move(tail(t)); return *this; } template @@ -157,7 +183,15 @@ namespace sprout { template tuple_impl& operator=(sprout::tuples::detail::tuple_impl&& t) { head(*this) = sprout::forward(sprout::tuples::detail::tuple_impl::head(t)); - tail(*this) = std::move(sprout::tuples::detail::tuple_impl::tail(t)); + tail(*this) = sprout::move(sprout::tuples::detail::tuple_impl::tail(t)); + return *this; + } + tuple_impl& operator=(sprout::tuples::detail::tuple_impl const& t) { + *this = sprout::move(tuple_impl()); + return *this; + } + tuple_impl& operator=(sprout::tuples::detail::tuple_impl&& t) { + *this = sprout::move(tuple_impl()); return *this; } }; @@ -180,17 +214,17 @@ namespace sprout { SPROUT_CONSTEXPR explicit tuple(Types const&... elements) : inherited_type(elements...) {} - template::type> + template SPROUT_CONSTEXPR explicit tuple(UTypes&&... elements) : inherited_type(sprout::forward(elements)...) {} SPROUT_CONSTEXPR tuple(tuple const &) = default; SPROUT_CONSTEXPR tuple(tuple&&) = default; - template::type> + template SPROUT_CONSTEXPR tuple(sprout::tuples::tuple const& t) : inherited_type(static_cast const&>(t)) {} - template::type> + template SPROUT_CONSTEXPR tuple(sprout::tuples::tuple&& t) : inherited_type(static_cast&&>(t)) {} @@ -200,17 +234,17 @@ namespace sprout { return *this; } tuple& operator=(tuple&& rhs) SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value) { - static_cast(*this) = std::move(rhs); + static_cast(*this) = sprout::move(rhs); return *this; } - template::type> + template tuple& operator=(sprout::tuples::tuple const& rhs) { static_cast(*this) = rhs; return *this; } - template::type> + template tuple& operator=(sprout::tuples::tuple&& rhs) { - static_cast(*this) = std::move(rhs); + static_cast(*this) = sprout::move(rhs); return *this; } // tuple swap diff --git a/sprout/utility.hpp b/sprout/utility.hpp index 7de2faff..552b8f9e 100644 --- a/sprout/utility.hpp +++ b/sprout/utility.hpp @@ -2,6 +2,6 @@ #define SPROUT_UTILITY_HPP #include -#include +#include #endif // #ifndef SPROUT_UTILITY_HPP diff --git a/sprout/utility/forward.hpp b/sprout/utility/forward.hpp index 6ab573b1..3a9e87bf 100644 --- a/sprout/utility/forward.hpp +++ b/sprout/utility/forward.hpp @@ -17,4 +17,3 @@ namespace sprout { } // namespace sprout #endif // #ifndef SPROUT_UTILITY_FORWARD_HPP - diff --git a/sprout/utility/move.hpp b/sprout/utility/move.hpp new file mode 100644 index 00000000..d965fb7a --- /dev/null +++ b/sprout/utility/move.hpp @@ -0,0 +1,17 @@ +#ifndef SPROUT_UTILITY_MOVE_HPP +#define SPROUT_UTILITY_MOVE_HPP + +#include +#include + +namespace sprout { + // + // move + // + template + SPROUT_CONSTEXPR typename std::remove_reference::type&& move(T&& t) SPROUT_NOEXCEPT { + return static_cast::type&&>(t); + } +} // namespace sprout + +#endif // #ifndef SPROUT_UTILITY_MOVE_HPP diff --git a/sprout/utility/operation.hpp b/sprout/utility/operation.hpp new file mode 100644 index 00000000..df6e1d40 --- /dev/null +++ b/sprout/utility/operation.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_UTILITY_OPERATION_HPP +#define SPROUT_UTILITY_OPERATION_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_UTILITY_OPERATION_HPP