I'm trying to figure out the difference between:
return std::adjacent_find(v.begin(), v.end(), std::not_equal_to<>()) == v.end();
and
return std::equal(v.begin() + 1, v.end(), v.begin());
The latter is bit shorter, so I'd prefer writing that, only difference I found being it crashes for empty arrays. Speed was about equal.
Aucun commentaire:
Enregistrer un commentaire