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

Unified Diff: src/zone/zone-allocator.h

Issue 2646873004: Enable emplace_back for zone containers (Closed)
Patch Set: Created 3 years, 11 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 | « src/wasm/wasm-text.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/zone/zone-allocator.h
diff --git a/src/zone/zone-allocator.h b/src/zone/zone-allocator.h
index 1e2862a2c1144b018884d6c55643f301c6bff3be..dfd1f95ae55e6301f00952cf7e90ca904d652b80 100644
--- a/src/zone/zone-allocator.h
+++ b/src/zone/zone-allocator.h
@@ -49,10 +49,15 @@ class zone_allocator {
size_type max_size() const throw() {
return std::numeric_limits<int>::max() / sizeof(value_type);
}
- void construct(pointer p, const T& val) {
- new (static_cast<void*>(p)) T(val);
+ template <typename U, typename... Args>
+ void construct(U* p, Args&&... args) {
+ void* v_p = const_cast<void*>(static_cast<const void*>(p));
+ new (v_p) U(std::forward<Args>(args)...);
+ }
+ template <typename U>
+ void destroy(U* p) {
+ p->~U();
}
- void destroy(pointer p) { p->~T(); }
bool operator==(zone_allocator const& other) const {
return zone_ == other.zone_;
« no previous file with comments | « src/wasm/wasm-text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698