Skip to content

Commit

Permalink
Introduce a range version of std::find, and use in SCEV
Browse files Browse the repository at this point in the history
Reviewers: dblaikie, pcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D15064

llvm-svn: 254391
  • Loading branch information
sanjoy committed Dec 1, 2015
1 parent ff3b8b4 commit 347d272
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions llvm/include/llvm/ADT/STLExtras.h
Expand Up @@ -379,6 +379,13 @@ bool any_of(R &&Range, UnaryPredicate &&P) {
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>
//===----------------------------------------------------------------------===//
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Analysis/ScalarEvolution.cpp
Expand Up @@ -7964,8 +7964,7 @@ static bool IsMaxConsistingOf(const SCEV *MaybeMaxExpr,
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();
}


Expand Down

0 comments on commit 347d272

Please sign in to comment.