[PATCH] D16053: contains() convenience function
Alexander Droste via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 11 05:26:49 PST 2016
Alexander_Droste updated the summary for this revision.
Alexander_Droste added a reviewer: dblaikie.
Alexander_Droste updated this revision to Diff 44471.
Alexander_Droste added a comment.
- changed name to `is_contained()` because `contains()` caused name conflicts
- adapted the style of other functions in `STLExtras.h`
- @David: I hope its ok that I added you as a reviewer. Googling for 'stlextras llvm reviewer' you
were the first author that appeared.
http://reviews.llvm.org/D16053
Files:
include/llvm/ADT/STLExtras.h
Index: include/llvm/ADT/STLExtras.h
===================================================================
--- include/llvm/ADT/STLExtras.h
+++ include/llvm/ADT/STLExtras.h
@@ -386,6 +386,13 @@
return std::find(Range.begin(), Range.end(), val);
}
+/// 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.44471.patch
Type: text/x-patch
Size: 705 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160111/2d54dc4e/attachment.bin>
More information about the llvm-commits
mailing list