diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-06-23 00:14:26 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-23 00:14:26 +0000 |
commit | 7867935f717d2ca150197c7193cafb88a41bdf4c (patch) | |
tree | 96a45a7bac41d00ccfdf551aa340522ef8999135 /include | |
parent | 788062df940eab65d97c06929d1a28f5ffa61576 (diff) |
[ADT] Add a range variant of std::transform
This will be used in a followup change in clang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273520 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/STLExtras.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 3d2ca9eb148..abd39dacc67 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -427,6 +427,14 @@ auto count_if(R &&Range, UnaryPredicate &&P) return std::count_if(Range.begin(), Range.end(), P); } +/// Wrapper function around std::transform to apply a function to a range and +/// store the result elsewhere. +template <typename R, class OutputIt, typename UnaryPredicate> +OutputIt transform(R &&Range, OutputIt d_first, UnaryPredicate &&P) { + return std::transform(Range.begin(), Range.end(), d_first, + std::forward<UnaryPredicate>(P)); +} + //===----------------------------------------------------------------------===// // Extra additions to <memory> //===----------------------------------------------------------------------===// |