[PATCH] D75208: [MLIR] Add `take_back()` to STLExtras.h for completeness.
Alexander Belyaev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 26 12:18:00 PST 2020
pifon2a created this revision.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
pifon2a added a reviewer: rriddle.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75208
Files:
mlir/include/mlir/Support/STLExtras.h
Index: mlir/include/mlir/Support/STLExtras.h
===================================================================
--- mlir/include/mlir/Support/STLExtras.h
+++ mlir/include/mlir/Support/STLExtras.h
@@ -268,6 +268,12 @@
: static_cast<const DerivedT &>(*this);
}
+ /// Take the last n elements.
+ DerivedT take_back(size_t n = 1) const {
+ return n < size() ? drop_front(size() - n)
+ : static_cast<const DerivedT &>(*this);
+ }
+
/// Allow conversion to SmallVector if necessary.
/// TODO(riverriddle) Remove this when SmallVector accepts different range
/// types in its constructor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75208.246812.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200226/024b00f0/attachment.bin>
More information about the llvm-commits
mailing list