[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 21:53:11 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGaff8c045a225: [MLIR] Add `take_back()` to STLExtras.h for completeness. (authored by pifon2a).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75208/new/

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.246880.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200227/3cf175d9/attachment.bin>


More information about the llvm-commits mailing list