]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/detail/include/boost/detail/is_sorted.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / detail / include / boost / detail / is_sorted.hpp
CommitLineData
7c673cae
FG
1/*==============================================================================
2 Copyright (c) 2010-2011 Bryce Lelbach
3
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6==============================================================================*/
7
8#ifndef BOOST_DETAIL_SORTED_HPP
9#define BOOST_DETAIL_SORTED_HPP
10
11#include <boost/detail/iterator.hpp>
12
13#include <functional>
14
15namespace boost {
16namespace detail {
17
18template<class Iterator, class Comp>
19inline Iterator is_sorted_until (Iterator first, Iterator last, Comp c) {
20 if (first == last)
21 return last;
22
23 Iterator it = first; ++it;
24
25 for (; it != last; first = it, ++it)
26 if (c(*it, *first))
27 return it;
28
29 return it;
30}
31
32template<class Iterator>
33inline Iterator is_sorted_until (Iterator first, Iterator last) {
34 typedef typename boost::detail::iterator_traits<Iterator>::value_type
35 value_type;
36
37 typedef std::less<value_type> c;
38
39 return ::boost::detail::is_sorted_until(first, last, c());
40}
41
42template<class Iterator, class Comp>
43inline bool is_sorted (Iterator first, Iterator last, Comp c) {
44 return ::boost::detail::is_sorted_until(first, last, c) == last;
45}
46
47template<class Iterator>
48inline bool is_sorted (Iterator first, Iterator last) {
49 return ::boost::detail::is_sorted_until(first, last) == last;
50}
51
52} // detail
53} // boost
54
55#endif // BOOST_DETAIL_SORTED_HPP
56