File indexing completed on 2025-01-18 09:40:51
0001 #ifndef BOOST_MOVE_DETAIL_IS_SORTED_HPP
0002 #define BOOST_MOVE_DETAIL_IS_SORTED_HPP
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_CONFIG_HPP
0014 # include <boost/config.hpp>
0015 #endif
0016
0017 #if defined(BOOST_HAS_PRAGMA_ONCE)
0018 # pragma once
0019 #endif
0020
0021 namespace boost {
0022 namespace movelib {
0023
0024 template<class ForwardIt, class Pred>
0025 bool is_sorted(ForwardIt const first, ForwardIt last, Pred pred)
0026 {
0027 if (first != last) {
0028 ForwardIt next = first, cur(first);
0029 while (++next != last) {
0030 if (pred(*next, *cur))
0031 return false;
0032 cur = next;
0033 }
0034 }
0035 return true;
0036 }
0037
0038 template<class ForwardIt, class Pred>
0039 bool is_sorted_and_unique(ForwardIt first, ForwardIt last, Pred pred)
0040 {
0041 if (first != last) {
0042 ForwardIt next = first;
0043 while (++next != last) {
0044 if (!pred(*first, *next))
0045 return false;
0046 first = next;
0047 }
0048 }
0049 return true;
0050 }
0051
0052 }
0053 }
0054
0055 #endif