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

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

Issue 2610113002: Enforce canCopyWithMemcpy constraint over TerminatedArray<T>. (Closed)
Patch Set: formatted 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/TerminatedArray.h
diff --git a/third_party/WebKit/Source/wtf/TerminatedArray.h b/third_party/WebKit/Source/wtf/TerminatedArray.h
index 873bc5b881a6c9e9f1dfcb90b45ff2b2236b4139..18193a4764a80ed26444d047e430fb8d8476dd74 100644
--- a/third_party/WebKit/Source/wtf/TerminatedArray.h
+++ b/third_party/WebKit/Source/wtf/TerminatedArray.h
@@ -6,6 +6,7 @@
#include "wtf/Allocator.h"
#include "wtf/PtrUtil.h"
+#include "wtf/VectorTraits.h"
#include "wtf/allocator/Partitions.h"
#include <memory>
@@ -21,6 +22,11 @@ class TerminatedArray {
WTF_MAKE_NONCOPYABLE(TerminatedArray);
public:
+ // When TerminatedArray::Allocator implementations grow the backing
+ // store, old is copied into the new and larger block.
+ static_assert(VectorTraits<T>::canCopyWithMemcpy,
+ "Array elements must be memory copyable");
+
T& at(size_t index) { return reinterpret_cast<T*>(this)[index]; }
const T& at(size_t index) const {
return reinterpret_cast<const T*>(this)[index];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698