[PATCH] D26999: Add some functions to search ArrayRefs

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 14:29:44 PST 2016


chandlerc added inline comments.


================
Comment at: include/llvm/ADT/ArrayRef.h:34
   public:
+    static const size_t npos = ~size_t(0);
     typedef const T *iterator;
----------------
I'm really reluctant to add APIs based around the 'npos' idea. How challenging does removing this and relying exclusively on iterator based constructs make things?


================
Comment at: include/llvm/ADT/ArrayRef.h:173
+    /// \p From, or npos if not found.
+    size_t find_if(function_ref<bool(const T &)> F, size_t From = 0) const {
+      ArrayRef<T> S = drop_front(From);
----------------
These are already inline functions, why not make them templates and use generic callables?


https://reviews.llvm.org/D26999





More information about the llvm-commits mailing list