<div dir="ltr">I think in the last review I/we were just suggesting to use any_of + equal_to directly & skip adding this extra construct entirely.<br><br>In any case, std::equal_to is a C++14 feature, so we probably can't use it in LLVM & the suggestion/discussion was about whether we could/should just implement one in LLVM (llvm::equal_to). But you also make a good point about equal_to needing a parameter/binding, blah blah - Ben: thoughts on that? Still nice if we have to use bind too? Could/should we make another function object to handle that more easily (the general case of a stateful unary equal_to, I mean)?<br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 17, 2016 at 1:28 PM, Alexander Droste via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Alexander_Droste retitled this revision from "contains() convenience function" to "is_contained() convenience function".<br>
Alexander_Droste updated this revision to Diff 45115.<br>
Alexander_Droste added a comment.<br>
<br>
- changed implementation to `std::equal_to<>` style<br>
<br>
<br>
<a href="http://reviews.llvm.org/D16053" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16053</a><br>
<br>
Files:<br>
  include/llvm/ADT/STLExtras.h<br>
<br>
Index: include/llvm/ADT/STLExtras.h<br>
===================================================================<br>
--- include/llvm/ADT/STLExtras.h<br>
+++ include/llvm/ADT/STLExtras.h<br>
@@ -386,6 +386,13 @@<br>
   return std::find(Range.begin(), Range.end(), val);<br>
 }<br>
<br>
+/// Wrapper function around llvm::any_of to detect if an element exists<br>
+/// in a container.<br>
+template <typename R, typename E><br>
+bool is_contained(R &&Range, const E &Element) {<br>
+    return any_of(Range, bind2nd(std::equal_to<E>(), Element));<br>
+}<br>
+<br>
 //===----------------------------------------------------------------------===//<br>
 //     Extra additions to <memory><br>
 //===----------------------------------------------------------------------===//<br>
<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>