
Joachim Faulhaber wrote:
Hi Grant,
2010/1/24 Grant Erickson <gerickson@nuovations.com>:
The creasing algorithm templates define four template functions for determining the order properties of sequences, specifically:
* Increasing * Decreasing * Strictly Increasing * Strictly Decreasing
in your implementation of 'creasing' you provide the four specific algorithms is_[strictly_]{in_,de_}creasing while hiding the general algorithm is_creasing in namespace detail.
I'd suggest to implement only the latter. This would make your extension both more minimal and more general.
template <typename ForwardIterator, typename BinaryPredicate> bool is_ordered(ForwardIterator first, ForwardIterator last, BinaryPredicate binary_pred) { return std::adjacent_find(first, last, std::not2(binary_pred)) == last; }
This looks a lot like the is_sorted algorithm from n3000: template<class ForwardIterator, class Compare> bool is_sorted(ForwardIterator first, ForwardIterator last, Compare comp); which also includes is_sorted_until: template<class ForwardIterator, class Compare> ForwardIterator is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);