[ADT] Add all_equal predicate
authorJakub Kuderski <kubak@google.com>
Tue, 23 Aug 2022 03:55:05 +0000 (23:55 -0400)
committerJakub Kuderski <kubak@google.com>
Tue, 23 Aug 2022 03:55:23 +0000 (23:55 -0400)
commitc9e52fbe4d4fa37a87b2855ad7e118dcdee2db68
tree02cb26fd25a7ef92c58b512f4f678f7dc20abb9b
parent2e36120726ee46cbfd3eee1e9244bdd756dee92d
[ADT] Add all_equal predicate

`llvm::all_equal` checks if all values in the given range are equal, i.e., there are no two elements that are not equal.
Similar to `llvm::all_of`, it returns `true` when the range is empty.

`llvm::all_equal` is intended to supersede `llvm::is_splat`, which will be deprecated and removed in future patches.
See the discussion thread for more details:
https://discourse.llvm.org/t/adt-is-splat-and-empty-ranges/64692.

Reviewed By: dblaikie, shchenz

Differential Revision: https://reviews.llvm.org/D132334
llvm/include/llvm/ADT/STLExtras.h
llvm/unittests/ADT/STLExtrasTest.cpp