aboutsummaryrefslogtreecommitdiff
path: root/src/prevector.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2020-02-15 19:09:09 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2020-02-15 19:49:24 -0800
commit56dd9f04c701aa3ac340e95065bf83de20373c8b (patch)
treed8515059063517e9b2388efb54e365152af1a77b /src/prevector.h
parent3ca574cef0b4423f21b2c3efd8f5c9f71d52f219 (diff)
Make VectorFormatter support stateful formatters
Diffstat (limited to 'src/prevector.h')
-rw-r--r--src/prevector.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/prevector.h b/src/prevector.h
index 09debedc4f..6d690e7f96 100644
--- a/src/prevector.h
+++ b/src/prevector.h
@@ -424,15 +424,20 @@ public:
return first;
}
- void push_back(const T& value) {
+ template<typename... Args>
+ void emplace_back(Args&&... args) {
size_type new_size = size() + 1;
if (capacity() < new_size) {
change_capacity(new_size + (new_size >> 1));
}
- new(item_ptr(size())) T(value);
+ new(item_ptr(size())) T(std::forward<Args>(args)...);
_size++;
}
+ void push_back(const T& value) {
+ emplace_back(value);
+ }
+
void pop_back() {
erase(end() - 1, end());
}