[PATCH] D16053: is_contained() convenience function
Devin Coughlin via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 17:56:31 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271757: STLExtras: Add convenience is_contained() function. (authored by dcoughlin).
Changed prior to commit:
http://reviews.llvm.org/D16053?vs=46836&id=59642#toc
Repository:
rL LLVM
http://reviews.llvm.org/D16053
Files:
llvm/trunk/include/llvm/ADT/STLExtras.h
Index: llvm/trunk/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h
+++ llvm/trunk/include/llvm/ADT/STLExtras.h
@@ -412,6 +412,13 @@
return std::remove_if(Range.begin(), Range.end(), P);
}
+/// Wrapper function around std::find to detect if an element exists
+/// in a container.
+template <typename R, typename E>
+bool is_contained(R &&Range, const E &Element) {
+ return std::find(Range.begin(), Range.end(), Element) != Range.end();
+}
+
//===----------------------------------------------------------------------===//
// Extra additions to <memory>
//===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16053.59642.patch
Type: text/x-patch
Size: 740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160604/cda5ea58/attachment.bin>
More information about the llvm-commits
mailing list