From e6bfb69be9212ac9a592c2bf7f9a1a7b89f96986 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Tue, 10 Apr 2012 02:36:49 +0900 Subject: [PATCH] fix tuple constructor --- sprout/tuple/tuple.hpp | 56 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/sprout/tuple/tuple.hpp b/sprout/tuple/tuple.hpp index 6d643c7b..d1dcf5e4 100644 --- a/sprout/tuple/tuple.hpp +++ b/sprout/tuple/tuple.hpp @@ -195,8 +195,45 @@ namespace sprout { return *this; } }; + + template + struct and_impl + : public std::false_type + {}; + template + struct and_impl + : public std::integral_constant::value> + {}; + + template + struct and_ + : public sprout::tuples::detail::and_impl + {}; } // namespace detail + template + class tuple; + + // + // is_tuple + // + template + struct is_tuple + : public std::false_type + {}; + template + struct is_tuple + : public sprout::tuples::is_tuple + {}; + template + struct is_tuple + : public sprout::tuples::is_tuple + {}; + template + struct is_tuple > + : public std::true_type + {}; + // // tuple // @@ -214,9 +251,22 @@ namespace sprout { SPROUT_CONSTEXPR explicit tuple(Types const&... elements) : inherited_type(elements...) {} - template - SPROUT_CONSTEXPR explicit tuple(UTypes&&... elements) - : inherited_type(sprout::forward(elements)...) + template< + typename U, + typename = typename std::enable_if< + !sprout::tuples::is_tuple::type>::value + >::type + > + SPROUT_CONSTEXPR explicit tuple(U&& elem) + : inherited_type(sprout::forward(elem)) + {} + template< + typename U1, + typename U2, + typename... UTypes + > + SPROUT_CONSTEXPR explicit tuple(U1&& elem1, U2&& elem2, UTypes&&... elements) + : inherited_type(sprout::forward(elem1), sprout::forward(elem2), sprout::forward(elements)...) {} SPROUT_CONSTEXPR tuple(tuple const&) = default; SPROUT_CONSTEXPR tuple(tuple&&) = default;