123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #ifndef BOOST_TUPLE_COMPARISON_HPP
- #define BOOST_TUPLE_COMPARISON_HPP
- #include "boost/tuple/tuple.hpp"
- namespace boost {
- namespace tuples {
- inline bool operator==(const null_type&, const null_type&) { return true; }
- inline bool operator>=(const null_type&, const null_type&) { return true; }
- inline bool operator<=(const null_type&, const null_type&) { return true; }
- inline bool operator!=(const null_type&, const null_type&) { return false; }
- inline bool operator<(const null_type&, const null_type&) { return false; }
- inline bool operator>(const null_type&, const null_type&) { return false; }
- namespace detail {
-
-
-
-
- template<class T1, class T2>
- inline bool eq(const T1& lhs, const T2& rhs) {
- return lhs.get_head() == rhs.get_head() &&
- eq(lhs.get_tail(), rhs.get_tail());
- }
- template<>
- inline bool eq<null_type,null_type>(const null_type&, const null_type&) { return true; }
- template<class T1, class T2>
- inline bool neq(const T1& lhs, const T2& rhs) {
- return lhs.get_head() != rhs.get_head() ||
- neq(lhs.get_tail(), rhs.get_tail());
- }
- template<>
- inline bool neq<null_type,null_type>(const null_type&, const null_type&) { return false; }
- template<class T1, class T2>
- inline bool lt(const T1& lhs, const T2& rhs) {
- return lhs.get_head() < rhs.get_head() ||
- ( !(rhs.get_head() < lhs.get_head()) &&
- lt(lhs.get_tail(), rhs.get_tail()));
- }
- template<>
- inline bool lt<null_type,null_type>(const null_type&, const null_type&) { return false; }
- template<class T1, class T2>
- inline bool gt(const T1& lhs, const T2& rhs) {
- return lhs.get_head() > rhs.get_head() ||
- ( !(rhs.get_head() > lhs.get_head()) &&
- gt(lhs.get_tail(), rhs.get_tail()));
- }
- template<>
- inline bool gt<null_type,null_type>(const null_type&, const null_type&) { return false; }
- template<class T1, class T2>
- inline bool lte(const T1& lhs, const T2& rhs) {
- return lhs.get_head() <= rhs.get_head() &&
- ( !(rhs.get_head() <= lhs.get_head()) ||
- lte(lhs.get_tail(), rhs.get_tail()));
- }
- template<>
- inline bool lte<null_type,null_type>(const null_type&, const null_type&) { return true; }
- template<class T1, class T2>
- inline bool gte(const T1& lhs, const T2& rhs) {
- return lhs.get_head() >= rhs.get_head() &&
- ( !(rhs.get_head() >= lhs.get_head()) ||
- gte(lhs.get_tail(), rhs.get_tail()));
- }
- template<>
- inline bool gte<null_type,null_type>(const null_type&, const null_type&) { return true; }
- }
- template<class T1, class T2, class S1, class S2>
- inline bool operator==(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
- {
-
- BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
- return detail::eq(lhs, rhs);
- }
- template<class T1, class T2, class S1, class S2>
- inline bool operator!=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
- {
-
- BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
- return detail::neq(lhs, rhs);
- }
- template<class T1, class T2, class S1, class S2>
- inline bool operator<(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
- {
-
- BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
- return detail::lt(lhs, rhs);
- }
- template<class T1, class T2, class S1, class S2>
- inline bool operator>(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
- {
-
- BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
- return detail::gt(lhs, rhs);
- }
- template<class T1, class T2, class S1, class S2>
- inline bool operator<=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
- {
-
- BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
- return detail::lte(lhs, rhs);
- }
- template<class T1, class T2, class S1, class S2>
- inline bool operator>=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
- {
-
- BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
- return detail::gte(lhs, rhs);
- }
- }
- }
- #endif
|