This is modeled after C++17 std::empty().
(I got talked into shaving this yak in D53885)
Paths
| Differential D53909
ADT/STLExtras: Introduce llvm::empty(); NFC ClosedPublic Authored by MatzeB on Oct 30 2018, 4:09 PM.
Details
Diff Detail
Event TimelineHerald added subscribers: kristina, dexonsmith, mcrosier. · View Herald TranscriptOct 30 2018, 4:10 PM Comment 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. This revision is now accepted and ready to land.Oct 30 2018, 4:56 PM 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) Closed by commit rL345679: ADT/STLExtras: Introduce llvm::empty; NFC (authored by matze). · Explain WhyOct 30 2018, 5:25 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 171837 include/llvm/ADT/STLExtras.h
lib/Analysis/LazyCallGraph.cpp
lib/CodeGen/GlobalISel/InstructionSelector.cpp
lib/CodeGen/GlobalISel/LegalizerInfo.cpp
lib/CodeGen/GlobalISel/RegBankSelect.cpp
lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
lib/ExecutionEngine/Orc/ExecutionUtils.cpp
lib/IR/DebugInfo.cpp
lib/Transforms/IPO/PartialInlining.cpp
lib/Transforms/Scalar/NewGVN.cpp
lib/Transforms/Utils/PredicateInfo.cpp
lib/Transforms/Utils/SimplifyCFG.cpp
unittests/ADT/STLExtrasTest.cpp
|