[Mlir-commits] [mlir] aff8c04 - [MLIR] Add `take_back()` to STLExtras.h for completeness.
Alexander Belyaev
llvmlistbot at llvm.org
Wed Feb 26 21:51:29 PST 2020
Author: Alexander Belyaev
Date: 2020-02-27T06:50:57+01:00
New Revision: aff8c045a225d98ee5fffa914e2493941f8465cd
URL: https://github.com/llvm/llvm-project/commit/aff8c045a225d98ee5fffa914e2493941f8465cd
DIFF: https://github.com/llvm/llvm-project/commit/aff8c045a225d98ee5fffa914e2493941f8465cd.diff
LOG: [MLIR] Add `take_back()` to STLExtras.h for completeness.
Differential Revision: https://reviews.llvm.org/D75208
Added:
Modified:
mlir/include/mlir/Support/STLExtras.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/Support/STLExtras.h b/mlir/include/mlir/Support/STLExtras.h
index 729e4583df46..b49278fc9fd0 100644
--- a/mlir/include/mlir/Support/STLExtras.h
+++ b/mlir/include/mlir/Support/STLExtras.h
@@ -268,6 +268,12 @@ class indexed_accessor_range_base {
: 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
diff erent range
/// types in its constructor.
More information about the Mlir-commits
mailing list