From d7561c95ddc989f4dba004554cab97ffadd28fe3 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 9 May 2013 16:55:40 +0900 Subject: [PATCH] fix tuple constrution: SFINAE bug (for GCC4.7.0) --- sprout/tuple/tuple/tuple.hpp | 52 +++++++++++++++++---- sprout/tuple/tuple/tuple_decl.hpp | 76 ++++++++++++++++++++++++------- 2 files changed, 102 insertions(+), 26 deletions(-) diff --git a/sprout/tuple/tuple/tuple.hpp b/sprout/tuple/tuple/tuple.hpp index 98038ab3..0fb38c3e 100644 --- a/sprout/tuple/tuple/tuple.hpp +++ b/sprout/tuple/tuple/tuple.hpp @@ -13,38 +13,70 @@ namespace sprout { // tuple // // tuple construction +// template +// template< +// typename... UTypes, +// typename +// > +// inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::pair const& t) +// : impl_type(t.first, t.second) +// {} +// template +// template< +// typename... UTypes, +// typename +// > +// inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::pair&& t) +// : impl_type(sprout::forward::first_type>(t.first), sprout::forward::second_type>(t.second)) +// {} template template< - typename... UTypes, + typename UType1, typename UType2, typename > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::pair const& t) + inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::pair const& t) : impl_type(t.first, t.second) {} template template< - typename... UTypes, + typename UType1, typename UType2, typename > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::pair&& t) - : impl_type(sprout::forward::first_type>(t.first), sprout::forward::second_type>(t.second)) + inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::pair&& t) + : impl_type(sprout::forward::first_type>(t.first), sprout::forward::second_type>(t.second)) {} +// template +// template< +// typename... UTypes, +// typename +// > +// inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t) +// : impl_type(t.first, t.second) +// {} +// template +// template< +// typename... UTypes, +// typename +// > +// inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t) +// : impl_type(sprout::forward::first_type>(t.first), sprout::forward::second_type>(t.second)) +// {} template template< - typename... UTypes, + typename UType1, typename UType2, typename > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t) + inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t) : impl_type(t.first, t.second) {} template template< - typename... UTypes, + typename UType1, typename UType2, typename > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t) - : impl_type(sprout::forward::first_type>(t.first), sprout::forward::second_type>(t.second)) + inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t) + : impl_type(sprout::forward::first_type>(t.first), sprout::forward::second_type>(t.second)) {} } // namespace tuples } // namespace sprout diff --git a/sprout/tuple/tuple/tuple_decl.hpp b/sprout/tuple/tuple/tuple_decl.hpp index ff802f4e..eaec8f73 100644 --- a/sprout/tuple/tuple/tuple_decl.hpp +++ b/sprout/tuple/tuple/tuple_decl.hpp @@ -271,6 +271,22 @@ namespace sprout { struct is_clvref_flexibly_convert_constructible : public is_flexibly_convert_constructible {}; + + template + struct is_fixedly_convert_constructible + : public std::integral_constant< + bool, + (sizeof...(UTypes) == sizeof...(Types) && is_flexibly_convert_constructible::value) + > + {}; + template + struct is_rvref_fixedly_convert_constructible + : public is_fixedly_convert_constructible + {}; + template + struct is_clvref_fixedly_convert_constructible + : public is_fixedly_convert_constructible + {}; public: // tuple construction SPROUT_CONSTEXPR tuple() @@ -308,20 +324,34 @@ namespace sprout { SPROUT_CONSTEXPR tuple(sprout::tuples::tuple&& t) : impl_type(static_cast&&>(t)) {} +// template< +// typename... UTypes, +// typename = typename std::enable_if< +// sizeof...(Types) == 2 && sprout::tpp::all_of...>::value +// >::type +// > +// SPROUT_CONSTEXPR tuple(sprout::pair const& t); +// template< +// typename... UTypes, +// typename = typename std::enable_if< +// sizeof...(Types) == 2 && sprout::tpp::all_of...>::value +// >::type +// > +// SPROUT_CONSTEXPR tuple(sprout::pair&& t); template< - typename... UTypes, + typename UType1, typename UType2, typename = typename std::enable_if< - sizeof...(Types) == 2 && sprout::tpp::all_of...>::value + is_clvref_fixedly_convert_constructible::value >::type > - SPROUT_CONSTEXPR tuple(sprout::pair const& t); + SPROUT_CONSTEXPR tuple(sprout::pair const& t); template< - typename... UTypes, + typename UType1, typename UType2, typename = typename std::enable_if< - sizeof...(Types) == 2 && sprout::tpp::all_of...>::value + is_rvref_fixedly_convert_constructible::value >::type > - SPROUT_CONSTEXPR tuple(sprout::pair&& t); + SPROUT_CONSTEXPR tuple(sprout::pair&& t); template< typename... UTypes, @@ -350,20 +380,34 @@ namespace sprout { SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple&& t) : impl_type(static_cast&&>(t)) {} +// template< +// typename... UTypes, +// typename = typename std::enable_if< +// is_clvref_flexibly_convert_constructible::value +// >::type +// > +// SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t); +// template< +// typename... UTypes, +// typename = typename std::enable_if< +// is_rvref_flexibly_convert_constructible::value +// >::type +// > +// SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t); template< - typename... UTypes, + typename UType1, typename UType2, typename = typename std::enable_if< - is_clvref_flexibly_convert_constructible::value + is_clvref_flexibly_convert_constructible::value >::type > - SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t); + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t); template< - typename... UTypes, + typename UType1, typename UType2, typename = typename std::enable_if< - is_rvref_flexibly_convert_constructible::value + is_rvref_flexibly_convert_constructible::value >::type > - SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t); + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t); // tuple assignment tuple& operator=(tuple const& rhs) { static_cast(*this) = rhs; @@ -415,10 +459,10 @@ namespace sprout { SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t) {} template SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple&& t) {} - template - SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t) {} - template - SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t) {} + template + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair const& t) {} + template + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t) {} // tuple swap void swap(tuple&) SPROUT_NOEXCEPT {} };