summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-03-16 02:41:45 +0000
committerFangrui Song <maskray@google.com>2019-03-16 02:41:45 +0000
commita957f47e0a362d13fa947a1218315a0c46ab6db6 (patch)
tree4c2bcb3814325afca5e2a6a2aa7d218cfe0b7da7
parent769b73738d7e9882dbb2318350374e2aef30de74 (diff)
downloadbcm5719-llvm-a957f47e0a362d13fa947a1218315a0c46ab6db6.tar.gz
bcm5719-llvm-a957f47e0a362d13fa947a1218315a0c46ab6db6.zip
[ADT] Make SmallVector emplace_back return a reference
This follows the C++17 std::vector change and can simplify immediate back() calls. llvm-svn: 356312
-rw-r--r--llvm/include/llvm/ADT/SmallVector.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index e3bfb90e1ba..96a49cd9550 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -318,6 +318,7 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T> {
public:
using iterator = typename SuperClass::iterator;
using const_iterator = typename SuperClass::const_iterator;
+ using reference = typename SuperClass::reference;
using size_type = typename SuperClass::size_type;
protected:
@@ -641,11 +642,12 @@ public:
insert(I, IL.begin(), IL.end());
}
- template <typename... ArgTypes> void emplace_back(ArgTypes &&... Args) {
+ template <typename... ArgTypes> reference emplace_back(ArgTypes &&... Args) {
if (LLVM_UNLIKELY(this->size() >= this->capacity()))
this->grow();
::new ((void *)this->end()) T(std::forward<ArgTypes>(Args)...);
this->set_size(this->size() + 1);
+ return this->back();
}
SmallVectorImpl &operator=(const SmallVectorImpl &RHS);
OpenPOWER on IntegriCloud