mirror of
https://github.com/boostorg/detail.git
synced 2025-07-31 12:57:14 +02:00
Fixed ambiguity issues when compiling with C++0x support enabled.
[SVN r68155]
This commit is contained in:
@@ -16,14 +16,14 @@ namespace boost {
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<class Iterator, class Comp>
|
template<class Iterator, class Comp>
|
||||||
inline Iterator is_sorted_until (Iterator first, Iterator last, Comp compare) {
|
inline Iterator is_sorted_until (Iterator first, Iterator last, Comp c) {
|
||||||
if (first == last)
|
if (first == last)
|
||||||
return last;
|
return last;
|
||||||
|
|
||||||
Iterator it = first; ++it;
|
Iterator it = first; ++it;
|
||||||
|
|
||||||
for (; it != last; first = it, ++it)
|
for (; it != last; first = it, ++it)
|
||||||
if (compare(*it, *first))
|
if (c(*it, *first))
|
||||||
return it;
|
return it;
|
||||||
|
|
||||||
return it;
|
return it;
|
||||||
@@ -34,19 +34,19 @@ inline Iterator is_sorted_until (Iterator first, Iterator last) {
|
|||||||
typedef typename boost::detail::iterator_traits<Iterator>::value_type
|
typedef typename boost::detail::iterator_traits<Iterator>::value_type
|
||||||
value_type;
|
value_type;
|
||||||
|
|
||||||
typedef std::less<value_type> compare;
|
typedef std::less<value_type> c;
|
||||||
|
|
||||||
return is_sorted_until(first, last, compare());
|
return ::boost::detail::is_sorted_until(first, last, c());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Iterator, class Comp>
|
template<class Iterator, class Comp>
|
||||||
inline bool is_sorted (Iterator first, Iterator last, Comp compare) {
|
inline bool is_sorted (Iterator first, Iterator last, Comp c) {
|
||||||
return is_sorted_until(first, last, compare) == last;
|
return ::boost::detail::is_sorted_until(first, last, c) == last;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Iterator>
|
template<class Iterator>
|
||||||
inline bool is_sorted (Iterator first, Iterator last) {
|
inline bool is_sorted (Iterator first, Iterator last) {
|
||||||
return is_sorted_until(first, last) == last;
|
return ::boost::detail::is_sorted_until(first, last) == last;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
|
@@ -71,9 +71,10 @@ struct tracking_greater_equal: std::binary_function <T, T, bool> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
using boost::detail::is_sorted;
|
#define IS_SORTED ::boost::detail::is_sorted
|
||||||
using boost::detail::is_sorted_until;
|
#define IS_SORTED_UNTIL ::boost::detail::is_sorted_until
|
||||||
using boost::array;
|
using boost::array;
|
||||||
using boost::report_errors;
|
using boost::report_errors;
|
||||||
|
|
||||||
@@ -88,41 +89,41 @@ int main (void) {
|
|||||||
tracking_greater<int> gt;
|
tracking_greater<int> gt;
|
||||||
tracking_greater_equal<int> gte;
|
tracking_greater_equal<int> gte;
|
||||||
|
|
||||||
BOOST_TEST_EQ(is_sorted_until(a.begin(), a.end()), a.end());
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(a.begin(), a.end()), a.end());
|
||||||
BOOST_TEST_EQ(is_sorted_until(a.begin(), a.end(), lt), a.end());
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(a.begin(), a.end(), lt), a.end());
|
||||||
BOOST_TEST_EQ(is_sorted_until(a.begin(), a.end(), lte), a.end());
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(a.begin(), a.end(), lte), a.end());
|
||||||
BOOST_TEST_EQ(*is_sorted_until(a.rbegin(), a.rend(), gt), *a.rend());
|
BOOST_TEST_EQ(*IS_SORTED_UNTIL(a.rbegin(), a.rend(), gt), *a.rend());
|
||||||
BOOST_TEST_EQ(*is_sorted_until(a.rbegin(), a.rend(), gte), *a.rend());
|
BOOST_TEST_EQ(*IS_SORTED_UNTIL(a.rbegin(), a.rend(), gte), *a.rend());
|
||||||
|
|
||||||
BOOST_TEST_EQ(is_sorted(a.begin(), a.end()), true);
|
BOOST_TEST_EQ(IS_SORTED(a.begin(), a.end()), true);
|
||||||
BOOST_TEST_EQ(is_sorted(a.begin(), a.end(), lt), true);
|
BOOST_TEST_EQ(IS_SORTED(a.begin(), a.end(), lt), true);
|
||||||
BOOST_TEST_EQ(is_sorted(a.begin(), a.end(), lte), true);
|
BOOST_TEST_EQ(IS_SORTED(a.begin(), a.end(), lte), true);
|
||||||
BOOST_TEST_EQ(is_sorted(a.rbegin(), a.rend(), gt), true);
|
BOOST_TEST_EQ(IS_SORTED(a.rbegin(), a.rend(), gt), true);
|
||||||
BOOST_TEST_EQ(is_sorted(a.rbegin(), a.rend(), gte), true);
|
BOOST_TEST_EQ(IS_SORTED(a.rbegin(), a.rend(), gte), true);
|
||||||
|
|
||||||
BOOST_TEST_EQ(is_sorted_until(b.begin(), b.end()), b.end());
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(b.begin(), b.end()), b.end());
|
||||||
BOOST_TEST_EQ(is_sorted_until(b.begin(), b.end(), lt), b.end());
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(b.begin(), b.end(), lt), b.end());
|
||||||
BOOST_TEST_EQ(is_sorted_until(b.begin(), b.end(), lte), &b[2]);
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(b.begin(), b.end(), lte), &b[2]);
|
||||||
BOOST_TEST_EQ(*is_sorted_until(b.rbegin(), b.rend(), gt), *b.rend());
|
BOOST_TEST_EQ(*IS_SORTED_UNTIL(b.rbegin(), b.rend(), gt), *b.rend());
|
||||||
BOOST_TEST_EQ(*is_sorted_until(b.rbegin(), b.rend(), gte), b[2]);
|
BOOST_TEST_EQ(*IS_SORTED_UNTIL(b.rbegin(), b.rend(), gte), b[2]);
|
||||||
|
|
||||||
BOOST_TEST_EQ(is_sorted(b.begin(), b.end()), true);
|
BOOST_TEST_EQ(IS_SORTED(b.begin(), b.end()), true);
|
||||||
BOOST_TEST_EQ(is_sorted(b.begin(), b.end(), lt), true);
|
BOOST_TEST_EQ(IS_SORTED(b.begin(), b.end(), lt), true);
|
||||||
BOOST_TEST_EQ(is_sorted(b.begin(), b.end(), lte), false);
|
BOOST_TEST_EQ(IS_SORTED(b.begin(), b.end(), lte), false);
|
||||||
BOOST_TEST_EQ(is_sorted(b.rbegin(), b.rend(), gt), true);
|
BOOST_TEST_EQ(IS_SORTED(b.rbegin(), b.rend(), gt), true);
|
||||||
BOOST_TEST_EQ(is_sorted(b.rbegin(), b.rend(), gte), false);
|
BOOST_TEST_EQ(IS_SORTED(b.rbegin(), b.rend(), gte), false);
|
||||||
|
|
||||||
BOOST_TEST_EQ(is_sorted_until(c.begin(), c.end()), &c[2]);
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(c.begin(), c.end()), &c[2]);
|
||||||
BOOST_TEST_EQ(is_sorted_until(c.begin(), c.end(), lt), &c[2]);
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(c.begin(), c.end(), lt), &c[2]);
|
||||||
BOOST_TEST_EQ(is_sorted_until(c.begin(), c.end(), lte), &c[2]);
|
BOOST_TEST_EQ(IS_SORTED_UNTIL(c.begin(), c.end(), lte), &c[2]);
|
||||||
BOOST_TEST_EQ(*is_sorted_until(c.rbegin(), c.rend(), gt), c[7]);
|
BOOST_TEST_EQ(*IS_SORTED_UNTIL(c.rbegin(), c.rend(), gt), c[7]);
|
||||||
BOOST_TEST_EQ(*is_sorted_until(c.rbegin(), c.rend(), gte), c[7]);
|
BOOST_TEST_EQ(*IS_SORTED_UNTIL(c.rbegin(), c.rend(), gte), c[7]);
|
||||||
|
|
||||||
BOOST_TEST_EQ(is_sorted(c.begin(), c.end()), false);
|
BOOST_TEST_EQ(IS_SORTED(c.begin(), c.end()), false);
|
||||||
BOOST_TEST_EQ(is_sorted(c.begin(), c.end(), lt), false);
|
BOOST_TEST_EQ(IS_SORTED(c.begin(), c.end(), lt), false);
|
||||||
BOOST_TEST_EQ(is_sorted(c.begin(), c.end(), lte), false);
|
BOOST_TEST_EQ(IS_SORTED(c.begin(), c.end(), lte), false);
|
||||||
BOOST_TEST_EQ(is_sorted(c.rbegin(), c.rend(), gt), false);
|
BOOST_TEST_EQ(IS_SORTED(c.rbegin(), c.rend(), gt), false);
|
||||||
BOOST_TEST_EQ(is_sorted(c.rbegin(), c.rend(), gte), false);
|
BOOST_TEST_EQ(IS_SORTED(c.rbegin(), c.rend(), gte), false);
|
||||||
|
|
||||||
return report_errors();
|
return report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user