Используйте holy_find в сочетании с меньшим или большим функтором.
Ограничение:
Вы должны знать, отсортирован ли контейнер по возрастанию или по убыванию.
Если vector
предполагается отсортировать в порядке возрастания:
//Checks the first element where adjacent value where elem > nextElem
//returns end if the vector is sorted!
//Complexity is O(n)
vector<int>::iterator pos = std::adjacent_find (aVec.begin(), aVec.end(), // range
std::greater<int>());
if (pos == aVec.end())
{
std::cout<<" sorted"<<endl;
}
else
{
std::cout<<"Not sorted"<<endl;
}