From a957f47e0a362d13fa947a1218315a0c46ab6db6 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 16 Mar 2019 02:41:45 +0000 Subject: [PATCH] [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 --- llvm/include/llvm/ADT/SmallVector.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index e3bfb90..96a49cd 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -318,6 +318,7 @@ class SmallVectorImpl : public SmallVectorTemplateBase { 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 void emplace_back(ArgTypes &&... Args) { + template reference emplace_back(ArgTypes &&... Args) { if (LLVM_UNLIKELY(this->size() >= this->capacity())) this->grow(); ::new ((void *)this->end()) T(std::forward(Args)...); this->set_size(this->size() + 1); + return this->back(); } SmallVectorImpl &operator=(const SmallVectorImpl &RHS); -- 2.7.4