12 /// Returns true if the sequence first,last is sorted, false if not.
14 bool sorted(For first, For last)
16 if (first == last) return true;
18 while (++tmp != last) {
19 if (*tmp < *first++) return false;
25 /// Cmp is the same Cmp as you would pass to std::sort.
26 template <class For, class Cmp>
27 bool sorted(For first, For last, Cmp cmp)
29 if (first == last) return true;
31 while (++tmp != last) {
32 if (cmp(*tmp, *first++)) return false;
39 template <class P1, class P2>
40 P1 operator()(std::pair<P1, P2> const & p) {
46 template <class InputIter, class OutputIter, class Func>
47 OutputIter copy_if(InputIter first, InputIter last,
48 OutputIter result, Func func)
50 for (; first != last; ++first) {
59 /// A slot in replacement for std::count for systems where it is broken.
60 template <class Iterator, class T>
61 typename std::iterator_traits<Iterator>::difference_type
62 count (Iterator first, Iterator last, T const & value)
65 return std::count(first, last, value);
67 std::iterator_traits<Iterator>::difference_type n = 0;
69 if (*first++ == value) ++n;