diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2017-11-03 20:01:25 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2017-11-03 20:01:25 +0000 |
commit | bdc30c02fb2f7dceab4499c871fc00aa9b7543b9 (patch) | |
tree | e6e7882f24aa24d956c0ea29398ee30dfc78e8dd /include | |
parent | b72a3a9da434080da25914c9eed94416b1adee40 (diff) |
Add llvm::for_each as a range-based extensions to <algorithm> and make use of it in some cases where it is a more clear alternative to std::for_each.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/STLExtras.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 3ec9dfe5de0..c42d976f467 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -813,6 +813,13 @@ void DeleteContainerSeconds(Container &C) { C.clear(); } +/// Provide wrappers to std::for_each which take ranges instead of having to
+/// pass begin/end explicitly.
+template <typename R, typename UnaryPredicate>
+UnaryPredicate for_each(R &&Range, UnaryPredicate P) {
+ return std::for_each(std::begin(Range), std::end(Range), P);
+}
+ /// Provide wrappers to std::all_of which take ranges instead of having to pass /// begin/end explicitly. template <typename R, typename UnaryPredicate> |