RosettaCodeData/Task/Compare-a-list-of-strings/C++/compare-a-list-of-strings.cpp
2023-07-01 13:44:08 -04:00

9 lines
391 B
C++

#include <algorithm>
#include <string>
// Bug: calling operator++ on an empty collection invokes undefined behavior.
std::all_of( ++(strings.begin()), strings.end(),
[&](std::string a){ return a == strings.front(); } ) // All equal
std::is_sorted( strings.begin(), strings.end(),
[](std::string a, std::string b){ return !(b < a); }) ) // Strictly ascending