Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: third_party/WebKit/Source/wtf/Vector.h

Issue 2739813003: Allow WTF::Vector::emplace_back accept one or zero arguments (Closed)
Patch Set: Added emplace_back() overload Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/VectorTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/Vector.h
diff --git a/third_party/WebKit/Source/wtf/Vector.h b/third_party/WebKit/Source/wtf/Vector.h
index c3ab13fc49f9953ef7b50aade2d1d39c6ff9fdd7..83b68093700736c88d086de3d55e5c4d1c66613e 100644
--- a/third_party/WebKit/Source/wtf/Vector.h
+++ b/third_party/WebKit/Source/wtf/Vector.h
@@ -1113,6 +1113,10 @@ class Vector
void push_back(U&&);
template <typename... Args>
T& emplace_back(Args&&...);
+ ALWAYS_INLINE T& emplace_back() {
+ grow(m_size + 1);
+ return back();
+ }
template <typename U>
void append(const U*, size_t);
template <typename U, size_t otherCapacity, typename V>
@@ -1667,9 +1671,6 @@ template <typename T, size_t inlineCapacity, typename Allocator>
template <typename... Args>
ALWAYS_INLINE T& Vector<T, inlineCapacity, Allocator>::emplace_back(
Args&&... args) {
- static_assert(sizeof...(Args), "grow() must be called instead");
- static_assert(sizeof...(Args) != 1, "append() must be called instead");
-
DCHECK(Allocator::isAllocationAllowed());
if (UNLIKELY(size() == capacity()))
expandCapacity(size() + 1);
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/VectorTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698