[llvm] r273520 - [ADT] Add a range variant of std::transform
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 22 17:14:26 PDT 2016
Author: majnemer
Date: Wed Jun 22 19:14:26 2016
New Revision: 273520
URL: http://llvm.org/viewvc/llvm-project?rev=273520&view=rev
Log:
[ADT] Add a range variant of std::transform
This will be used in a followup change in clang.
Modified:
llvm/trunk/include/llvm/ADT/STLExtras.h
Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=273520&r1=273519&r2=273520&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Wed Jun 22 19:14:26 2016
@@ -427,6 +427,14 @@ auto count_if(R &&Range, UnaryPredicate
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>
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list