From 44f973cc193abd8b93f153a157b72e16b7769116 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 31 Mar 2013 18:20:59 +0900 Subject: [PATCH] fix for GCC4.8 --- sprout/tuple/tuple/tuple.hpp | 131 ------------------------------ sprout/tuple/tuple/tuple_decl.hpp | 90 +++++++++++++------- sprout/utility/pair/pair.hpp | 89 -------------------- sprout/utility/pair/pair_decl.hpp | 60 +++++++++++--- testspr/iterator.hpp | 2 +- 5 files changed, 110 insertions(+), 262 deletions(-) diff --git a/sprout/tuple/tuple/tuple.hpp b/sprout/tuple/tuple/tuple.hpp index 814f02b4..98038ab3 100644 --- a/sprout/tuple/tuple/tuple.hpp +++ b/sprout/tuple/tuple/tuple.hpp @@ -1,15 +1,9 @@ #ifndef SPROUT_TUPLE_TUPLE_TUPLE_HPP #define SPROUT_TUPLE_TUPLE_TUPLE_HPP -#include -#include #include #include -#include -#include #include -#include -#include #include #include @@ -20,42 +14,6 @@ namespace sprout { // // tuple construction template - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple() - : impl_type() - {} - template - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(Types const&... elements) - : impl_type(elements...) - {} - template - template< - typename... UTypes, - typename - > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(UTypes&&... elements) - : impl_type(sprout::forward(elements)...) - {} - template - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(tuple const&) = default; - template - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(tuple&&) = default; - template - template< - typename... UTypes, - typename - > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::tuple const& t) - : impl_type(static_cast const&>(t)) - {} - template - template< - typename... UTypes, - typename - > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::tuple&& t) - : impl_type(static_cast&&>(t)) - {} - template template< typename... UTypes, typename @@ -72,30 +30,6 @@ namespace sprout { : 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, UTypes&&... elements) - : impl_type(sprout::forward(elements)...) - {} - template - template< - typename... UTypes, - typename - > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t) - : impl_type(static_cast const&>(t)) - {} - template - template< - typename... UTypes, - typename - > - inline SPROUT_CONSTEXPR sprout::tuples::tuple::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple&& t) - : impl_type(static_cast&&>(t)) - {} template template< typename... UTypes, @@ -112,71 +46,6 @@ namespace sprout { 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)) {} - // tuple assignment - template - sprout::tuples::tuple& sprout::tuples::tuple::operator=(tuple const& rhs) { - static_cast(*this) = rhs; - return *this; - } - template - sprout::tuples::tuple& sprout::tuples::tuple::operator=(tuple&& rhs) - SPROUT_NOEXCEPT_EXPR(sprout::tpp::all_of...>::value) - { - static_cast(*this) = sprout::move(rhs); - return *this; - } - template - template< - typename... UTypes, - typename - > - sprout::tuples::tuple& sprout::tuples::tuple::operator=(sprout::tuples::tuple const& rhs) { - static_cast(*this) = rhs; - return *this; - } - template - template< - typename... UTypes, - typename - > - sprout::tuples::tuple& sprout::tuples::tuple::operator=(sprout::tuples::tuple&& rhs) { - static_cast(*this) = sprout::move(rhs); - return *this; - } - // tuple swap - template - inline void sprout::tuples::tuple::swap(tuple& other) - SPROUT_NOEXCEPT_EXPR(has_nothrow_swap::value) - { - impl_type::swap(other); - } - - // - // tuple - // - // tuple construction - inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple() = default; - inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(tuple const&) = default; - inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(tuple&&) = default; - template - inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements) {} - template - inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t) {} - template - inline SPROUT_CONSTEXPR sprout::tuples::tuple<>::tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple&& t) {} - // tuple swap - inline void sprout::tuples::tuple<>::swap(tuple&) SPROUT_NOEXCEPT {} - - // - // swap - // - template - inline void - swap(sprout::tuples::tuple& lhs, sprout::tuples::tuple& rhs) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) - { - lhs.swap(rhs); - } } // namespace tuples } // namespace sprout diff --git a/sprout/tuple/tuple/tuple_decl.hpp b/sprout/tuple/tuple/tuple_decl.hpp index 6047d5ef..c4882e0d 100644 --- a/sprout/tuple/tuple/tuple_decl.hpp +++ b/sprout/tuple/tuple/tuple_decl.hpp @@ -256,11 +256,6 @@ namespace sprout { > {}; public: - struct has_nothrow_swap - : public sprout::tpp::all_of_c< - SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(sprout::swap(std::declval(), std::declval()), false)... - > - {}; template struct is_flexibly_convert_constructible : public is_flexibly_convert_constructible_impl< @@ -278,31 +273,41 @@ namespace sprout { {}; public: // tuple construction - SPROUT_CONSTEXPR tuple(); - explicit SPROUT_CONSTEXPR tuple(Types const&... elements); + SPROUT_CONSTEXPR tuple() + : impl_type() + {} + explicit SPROUT_CONSTEXPR tuple(Types const&... elements) + : impl_type(elements...) + {} template< typename... UTypes, typename = typename std::enable_if< sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value >::type > - explicit SPROUT_CONSTEXPR tuple(UTypes&&... elements); - SPROUT_CONSTEXPR tuple(tuple const&); - SPROUT_CONSTEXPR tuple(tuple&&); + explicit SPROUT_CONSTEXPR tuple(UTypes&&... elements) + : impl_type(sprout::forward(elements)...) + {} + SPROUT_CONSTEXPR tuple(tuple const&) = default; + SPROUT_CONSTEXPR tuple(tuple&&) = default; template< typename... UTypes, typename = typename std::enable_if< sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value >::type > - SPROUT_CONSTEXPR tuple(sprout::tuples::tuple const& t); + SPROUT_CONSTEXPR tuple(sprout::tuples::tuple const& t) + : impl_type(static_cast const&>(t)) + {} template< typename... UTypes, typename = typename std::enable_if< sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value >::type > - SPROUT_CONSTEXPR tuple(sprout::tuples::tuple&& t); + SPROUT_CONSTEXPR tuple(sprout::tuples::tuple&& t) + : impl_type(static_cast&&>(t)) + {} template< typename... UTypes, typename = typename std::enable_if< @@ -324,21 +329,27 @@ namespace sprout { is_rvref_flexibly_convert_constructible::value >::type > - explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements); + explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements) + : impl_type(sprout::forward(elements)...) + {} template< typename... UTypes, typename = typename std::enable_if< is_clvref_flexibly_convert_constructible::value >::type > - SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t); + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t) + : impl_type(static_cast 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::tuples::tuple&& t); + 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< @@ -354,42 +365,62 @@ namespace sprout { > SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::pair&& t); // tuple assignment - tuple& operator=(tuple const& rhs); + tuple& operator=(tuple const& rhs) { + static_cast(*this) = rhs; + return *this; + } tuple& operator=(tuple&& rhs) - SPROUT_NOEXCEPT_EXPR(sprout::tpp::all_of...>::value); + SPROUT_NOEXCEPT_EXPR(sprout::tpp::all_of...>::value) + { + static_cast(*this) = sprout::move(rhs); + return *this; + } template< typename... UTypes, typename = typename std::enable_if< sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value >::type > - tuple& operator=(sprout::tuples::tuple const& rhs); + tuple& operator=(sprout::tuples::tuple const& rhs) { + static_cast(*this) = rhs; + return *this; + } template< typename... UTypes, typename = typename std::enable_if< sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value >::type > - tuple& operator=(sprout::tuples::tuple&& rhs); + tuple& operator=(sprout::tuples::tuple&& rhs) { + static_cast(*this) = sprout::move(rhs); + return *this; + } // tuple swap void swap(tuple& other) - SPROUT_NOEXCEPT_EXPR(has_nothrow_swap::value); + SPROUT_NOEXCEPT_EXPR(sprout::tpp::all_of_c(), std::declval()), false)...>::value) + { + impl_type::swap(other); + } }; template<> class tuple<> { public: // tuple construction - SPROUT_CONSTEXPR tuple(); - SPROUT_CONSTEXPR tuple(tuple const&); - SPROUT_CONSTEXPR tuple(tuple&&); + SPROUT_CONSTEXPR tuple() = default; + SPROUT_CONSTEXPR tuple(tuple const&) = default; + SPROUT_CONSTEXPR tuple(tuple&&) = default; template - explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements); + explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements) {} template - SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t); + 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); + 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) {} // tuple swap - void swap(tuple&) SPROUT_NOEXCEPT; + void swap(tuple&) SPROUT_NOEXCEPT {} }; // @@ -398,7 +429,10 @@ namespace sprout { template inline void swap(sprout::tuples::tuple& lhs, sprout::tuples::tuple& rhs) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))); + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) + { + lhs.swap(rhs); + } namespace detail { template diff --git a/sprout/utility/pair/pair.hpp b/sprout/utility/pair/pair.hpp index d965ceb6..3e3df30f 100644 --- a/sprout/utility/pair/pair.hpp +++ b/sprout/utility/pair/pair.hpp @@ -26,47 +26,6 @@ namespace sprout { : first(sprout::tuples::get(first_args)...) , second(sprout::tuples::get(second_args)...) {} - template - inline SPROUT_CONSTEXPR sprout::pair::pair(pair const&) = default; - template - inline SPROUT_CONSTEXPR sprout::pair::pair(pair&&) = default; - template - inline SPROUT_CONSTEXPR sprout::pair::pair() - : first() - , second() - {} - template - inline SPROUT_CONSTEXPR sprout::pair::pair(T1 const& x, T2 const& y) - : first(x) - , second(y) - {} - template - template< - typename U, typename V, - typename - > - inline SPROUT_CONSTEXPR sprout::pair::pair(U&& x, V&& y) - : first(sprout::forward(x)) - , second(sprout::forward(y)) - {} - template - template< - typename U, typename V, - typename - > - inline SPROUT_CONSTEXPR sprout::pair::pair(sprout::pair const& other) - : first(other.first) - , second(other.second) - {} - template - template< - typename U, typename V, - typename - > - inline SPROUT_CONSTEXPR sprout::pair::pair(sprout::pair&& other) - : first(sprout::forward(other.first)) - , second(sprout::forward(other.second)) - {} #if SPROUT_USE_DELEGATING_CONSTRUCTORS template template< @@ -104,36 +63,6 @@ namespace sprout { , second(sprout::forward(sprout::tuples::get<1>(other))) {} - template - inline sprout::pair& sprout::pair::operator=(pair const& rhs) = default; - template - inline sprout::pair& sprout::pair::operator=(pair&& rhs) - SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) - { - first = sprout::forward(rhs.first); - second = sprout::forward(rhs.second); - return *this; - } - template - template< - typename U, typename V, - typename - > - inline sprout::pair& sprout::pair::operator=(sprout::pair const& rhs) { - first = rhs.first; - second = rhs.second; - return *this; - } - template - template< - typename U, typename V, - typename - > - inline sprout::pair& sprout::pair::operator=(sprout::pair&& rhs) { - first = sprout::forward(rhs.first); - second = sprout::forward(rhs.second); - return *this; - } template template< typename U, typename V, @@ -154,24 +83,6 @@ namespace sprout { second = sprout::forward(sprout::tuples::get<1>(rhs)); return *this; } - - template - inline void sprout::pair::swap(pair& other) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))) { - sprout::swap(first, other.first); - sprout::swap(second, other.second); - } - - // - // swap - // - template - inline void - swap(sprout::pair& lhs, sprout::pair& rhs) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) - { - lhs.swap(rhs); - } } // namespace sprout #endif // #ifndef SPROUT_UTILITY_PAIR_PAIR_HPP diff --git a/sprout/utility/pair/pair_decl.hpp b/sprout/utility/pair/pair_decl.hpp index 0062c4ff..8d38f373 100644 --- a/sprout/utility/pair/pair_decl.hpp +++ b/sprout/utility/pair/pair_decl.hpp @@ -31,31 +31,46 @@ namespace sprout { sprout::index_tuple ); public: - SPROUT_CONSTEXPR pair(pair const&); - SPROUT_CONSTEXPR pair(pair&&); - SPROUT_CONSTEXPR pair(); - SPROUT_CONSTEXPR pair(T1 const& x, T2 const& y); + SPROUT_CONSTEXPR pair() + : first() + , second() + {} + SPROUT_CONSTEXPR pair(pair const&) = default; + SPROUT_CONSTEXPR pair(pair&&) = default; + SPROUT_CONSTEXPR pair(T1 const& x, T2 const& y) + : first(x) + , second(y) + {} template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > - SPROUT_CONSTEXPR pair(U&& x, V&& y); + SPROUT_CONSTEXPR pair(U&& x, V&& y) + : first(sprout::forward(x)) + , second(sprout::forward(y)) + {} template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > - SPROUT_CONSTEXPR pair(sprout::pair const& other); + SPROUT_CONSTEXPR pair(sprout::pair const& other) + : first(other.first) + , second(other.second) + {} template< typename U, typename V, typename = typename std::enable_if< std::is_constructible::value && std::is_constructible::value >::type > - SPROUT_CONSTEXPR pair(sprout::pair&& other); + SPROUT_CONSTEXPR pair(sprout::pair&& other) + : first(sprout::forward(other.first)) + , second(sprout::forward(other.second)) + {} template< typename... Args1, typename... Args2, typename = typename std::enable_if< @@ -82,23 +97,36 @@ namespace sprout { > SPROUT_CONSTEXPR pair(sprout::tuples::tuple&& other); - pair& operator=(pair const& rhs); + pair& operator=(pair const& rhs) = default; pair& operator=(pair&& rhs) - SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value); + SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) + { + first = sprout::forward(rhs.first); + second = sprout::forward(rhs.second); + return *this; + } template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > - pair& operator=(sprout::pair const& rhs); + pair& operator=(sprout::pair const& rhs) { + first = rhs.first; + second = rhs.second; + return *this; + } template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > - pair& operator=(sprout::pair&& rhs); + pair& operator=(sprout::pair&& rhs) { + first = sprout::forward(rhs.first); + second = sprout::forward(rhs.second); + return *this; + } template< typename U, typename V, typename = typename std::enable_if< @@ -115,7 +143,10 @@ namespace sprout { pair& operator=(sprout::tuples::tuple&& rhs); void swap(pair& other) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))); + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))) { + sprout::swap(first, other.first); + sprout::swap(second, other.second); + } }; // @@ -124,7 +155,10 @@ namespace sprout { template inline void swap(sprout::pair& lhs, sprout::pair& rhs) - SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))); + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) + { + lhs.swap(rhs); + } } // namespace sprout #endif // #ifndef SPROUT_UTILITY_PAIR_PAIR_DECL_HPP diff --git a/testspr/iterator.hpp b/testspr/iterator.hpp index d2d0b245..1d7c07d1 100644 --- a/testspr/iterator.hpp +++ b/testspr/iterator.hpp @@ -33,7 +33,7 @@ namespace testspr { protected: iterator_type current; public: - reduct_iterator() = default; + SPROUT_CONSTEXPR reduct_iterator() {}; SPROUT_CONSTEXPR reduct_iterator(reduct_iterator const& other) = default; explicit SPROUT_CONSTEXPR reduct_iterator(iterator_type it) : current(it)