This is modeled after C++17 std::empty().
(I got talked into shaving this yak in D53885)
Differential D53909
ADT/STLExtras: Introduce llvm::empty(); NFC MatzeB on Oct 30 2018, 4:09 PM. Authored by
Details
Diff Detail
Event TimelineComment Actions (maybe some unit tests?) Also, what about having only a single implementation: template <typename Range> constexpr bool empty(const Range &r) { return adl_begin(r) == adl_end(r); } Not sure why the standard library doesn't do it this way, but there are probably good reasons... though maybe they don't apply to us/llvm? Comment Actions What if the container has an optimized empty() method that works faster than actually producing begin and end iterators? Comment Actions
Comment Actions Sure - let's go with your original solution (plus the test case) for forwards-compatibility with the standard. Comment Actions (oh, if you are going to switch back to the original implementation - probably put "empty" for iterator_range in iterator_range, rather than as a non-member) |