13 /// Returns true if the sequence first,last is sorted, false if not.
15 bool sorted(For first, For last)
17 if (first == last) return true;
19 while (++tmp != last) {
20 if (*tmp < *first++) return false;
26 /// Cmp is the same Cmp as you would pass to std::sort.
27 template <class For, class Cmp>
28 bool sorted(For first, For last, Cmp cmp)
30 if (first == last) return true;
32 while (++tmp != last) {
33 if (cmp(*tmp, *first++)) return false;
40 template <class P1, class P2>
41 P1 operator()(std::pair<P1, P2> const & p) {
47 template <class InputIter, class OutputIter, class Func>
48 OutputIter copy_if(InputIter first, InputIter last,
49 OutputIter result, Func func)
51 for (; first != last; ++first) {
60 /// A slot in replacement for std::count for systems where it is broken.
61 template <class Iterator, class T>
62 typename std::iterator_traits<Iterator>::difference_type
63 count (Iterator first, Iterator last, T const & value)
66 return std::count(first, last, value);
68 std::iterator_traits<Iterator>::difference_type n = 0;
70 if (*first++ == value) ++n;