4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
11 * A variety of useful templates.
20 /// Returns true if the sequence first,last is sorted, false if not.
22 bool sorted(For first, For last)
24 if (first == last) return true;
26 while (++tmp != last) {
27 if (*tmp < *first++) return false;
33 /// Cmp is the same Cmp as you would pass to std::sort.
34 template <class For, class Cmp>
35 bool sorted(For first, For last, Cmp cmp)
37 if (first == last) return true;
39 while (++tmp != last) {
40 if (cmp(*tmp, *first++)) return false;