[PATCH] D15064: Introduce a range version of std::find, and use in SCEV
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 30 23:52:34 PST 2015
This revision was automatically updated to reflect the committed changes.
Closed by commit rL254391: Introduce a range version of std::find, and use in SCEV (authored by sanjoy).
Changed prior to commit:
http://reviews.llvm.org/D15064?vs=41361&id=41468#toc
Repository:
rL LLVM
http://reviews.llvm.org/D15064
Files:
llvm/trunk/include/llvm/ADT/STLExtras.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Index: llvm/trunk/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h
+++ llvm/trunk/include/llvm/ADT/STLExtras.h
@@ -379,6 +379,13 @@
std::forward<UnaryPredicate>(P));
}
+/// Provide wrappers to std::find which take ranges instead of having to pass
+/// begin/end explicitly.
+template<typename R, class T>
+auto find(R &&Range, const T &val) -> decltype(Range.begin()) {
+ return std::find(Range.begin(), Range.end(), val);
+}
+
//===----------------------------------------------------------------------===//
// Extra additions to <memory>
//===----------------------------------------------------------------------===//
Index: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp
@@ -7964,8 +7964,7 @@
const MaxExprType *MaxExpr = dyn_cast<MaxExprType>(MaybeMaxExpr);
if (!MaxExpr) return false;
- auto It = std::find(MaxExpr->op_begin(), MaxExpr->op_end(), Candidate);
- return It != MaxExpr->op_end();
+ return find(MaxExpr->operands(), Candidate) != MaxExpr->op_end();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15064.41468.patch
Type: text/x-patch
Size: 1271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151201/3795dd35/attachment.bin>
More information about the llvm-commits
mailing list