1 // Copyright Neil Groves 2009. Use, modification and
2 // distribution is subject to the Boost Software License, Version
3 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org/libs/range/
9 #ifndef BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
10 #define BOOST_RANGE_ALGORITHM_LEXICOGRAPHICAL_COMPARE_HPP_INCLUDED
12 #include <boost/concept_check.hpp>
13 #include <boost/range/begin.hpp>
14 #include <boost/range/end.hpp>
15 #include <boost/range/concepts.hpp>
23 /// \brief template function lexicographic_compare
25 /// range-based version of the lexicographic_compare std algorithm
27 /// \pre SinglePassRange1 is a model of the SinglePassRangeConcept
28 /// \pre SinglePassRange2 is a model of the SinglePassRangeConcept
29 template<class SinglePassRange1, class SinglePassRange2>
30 inline bool lexicographical_compare(const SinglePassRange1& rng1,
31 const SinglePassRange2& rng2)
33 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
34 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
35 return std::lexicographical_compare(
36 boost::begin(rng1), boost::end(rng1),
37 boost::begin(rng2), boost::end(rng2));
41 template<class SinglePassRange1, class SinglePassRange2,
42 class BinaryPredicate>
43 inline bool lexicographical_compare(const SinglePassRange1& rng1,
44 const SinglePassRange2& rng2,
47 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
48 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
49 return std::lexicographical_compare(
50 boost::begin(rng1), boost::end(rng1),
51 boost::begin(rng2), boost::end(rng2), pred);
55 using range::lexicographical_compare;
58 #endif // include guard