/usr/include/boost/tuple/tuple_comparison.hpp is in libboost1.46-dev 1.46.1-7ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | // tuple_comparison.hpp -----------------------------------------------------
//
// Copyright (C) 2001 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
// Copyright (C) 2001 Gary Powell (gary.powell@sierra.com)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org
//
// (The idea and first impl. of comparison operators was from Doug Gregor)
// -----------------------------------------------------------------
#ifndef BOOST_TUPLE_COMPARISON_HPP
#define BOOST_TUPLE_COMPARISON_HPP
#include "boost/tuple/tuple.hpp"
// -------------------------------------------------------------
// equality and comparison operators
//
// == and != compare tuples elementwise
// <, >, <= and >= use lexicographical ordering
//
// Any operator between tuples of different length fails at compile time
// No dependencies between operators are assumed
// (i.e. !(a<b) does not imply a>=b, a!=b does not imply a==b etc.
// so any weirdnesses of elementary operators are respected).
//
// -------------------------------------------------------------
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 {
// comparison operators check statically the length of its operands and
// delegate the comparing task to the following functions. Hence
// the static check is only made once (should help the compiler).
// These functions assume tuples to be of the same length.
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; }
} // end of namespace detail
// equal ----
template<class T1, class T2, class S1, class S2>
inline bool operator==(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
{
// check that tuple lengths are equal
BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
return detail::eq(lhs, rhs);
}
// not equal -----
template<class T1, class T2, class S1, class S2>
inline bool operator!=(const cons<T1, T2>& lhs, const cons<S1, S2>& rhs)
{
// check that tuple lengths are equal
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)
{
// check that tuple lengths are equal
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)
{
// check that tuple lengths are equal
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)
{
// check that tuple lengths are equal
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)
{
// check that tuple lengths are equal
BOOST_STATIC_ASSERT(length<T2>::value == length<S2>::value);
return detail::gte(lhs, rhs);
}
} // end of namespace tuples
} // end of namespace boost
#endif // BOOST_TUPLE_COMPARISON_HPP
|