#ifndef SPROUT_TUPLE_TUPLE_COMPARISON_HPP #define SPROUT_TUPLE_TUPLE_COMPARISON_HPP #include #include #include namespace sprout { namespace tuples { // // operator== // operator< // operator!= // operator> // operator>= // operator<= // namespace detail { template struct tuple_compare; template struct tuple_compare<0, I, I, T, U> { public: static SPROUT_CONSTEXPR bool eq(T const&, U const&) { return true; } static SPROUT_CONSTEXPR bool less(T const&, U const&) { return false; } }; template struct tuple_compare<0, I, J, T, U> { public: static SPROUT_CONSTEXPR bool eq(T const& t, U const& u) { return (sprout::tuples::get(t) == sprout::tuples::get(u) && sprout::tuples::detail::tuple_compare<0, I + 1, J, T, U>::eq(t, u)) ; } static SPROUT_CONSTEXPR bool less(T const& t, U const& u) { return (sprout::tuples::get(t) < sprout::tuples::get(u)) || (!(sprout::tuples::get(u) < sprout::tuples::get(t)) && sprout::tuples::detail::tuple_compare<0, I + 1, J, T, U>::less(t, u) ) ; } }; } // namespace detail template SPROUT_CONSTEXPR inline bool operator==( sprout::tuples::tuple const& lhs, sprout::tuples::tuple const& rhs ) { typedef sprout::tuples::tuple T; typedef sprout::tuples::tuple U; return sprout::tuples::detail::tuple_compare< sprout::tuples::tuple_size::value - sprout::tuples::tuple_size::value, 0, sprout::tuples::tuple_size::value, T, U >::eq(lhs, rhs); } template SPROUT_CONSTEXPR inline bool operator<( sprout::tuples::tuple const& lhs, sprout::tuples::tuple const& rhs ) { typedef sprout::tuples::tuple T; typedef sprout::tuples::tuple U; return sprout::tuples::detail::tuple_compare< sprout::tuples::tuple_size::value - sprout::tuples::tuple_size::value, 0, sprout::tuples::tuple_size::value, T, U >::less(lhs, rhs); } template SPROUT_CONSTEXPR inline bool operator!=( sprout::tuples::tuple const& lhs, sprout::tuples::tuple const& rhs ) { return !(lhs == rhs); } template SPROUT_CONSTEXPR inline bool operator>( sprout::tuples::tuple const& lhs, sprout::tuples::tuple const& rhs ) { return rhs < lhs; } template SPROUT_CONSTEXPR inline bool operator<=( sprout::tuples::tuple const& lhs, sprout::tuples::tuple const& rhs ) { return !(rhs < lhs); } template SPROUT_CONSTEXPR inline bool operator>=( sprout::tuples::tuple const& lhs, sprout::tuples::tuple const& rhs ) { return !(lhs < rhs); } } // namespace tuples } // namespace sprout #endif // #ifndef SPROUT_TUPLE_TUPLE_COMPARISON_HPP