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 171846 llvm/trunk/include/llvm/ADT/STLExtras.h
llvm/trunk/lib/Analysis/LazyCallGraph.cpp
llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
llvm/trunk/lib/ExecutionEngine/Orc/ExecutionUtils.cpp
llvm/trunk/lib/IR/DebugInfo.cpp
llvm/trunk/lib/Transforms/IPO/PartialInlining.cpp
llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
llvm/trunk/lib/Transforms/Utils/PredicateInfo.cpp
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/unittests/ADT/STLExtrasTest.cpp
|