From f037d4df1680aecefac2ffb240547385a74971d0 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Fri, 6 Oct 2017 21:05:38 -0500 Subject: COMMON: Allow construction of Arrays of non-copyable members Although the previous count-constructor would never make a copy of a member at runtime, Array::reserve *may* copy-construct, so the compiler would forbid creation of arrays of NonCopyable objects even when the array was created only once and then never resized (and thus never actually tried to perform a copy-construction). --- common/array.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/array.h b/common/array.h index 1645db05b1..d4dac35866 100644 --- a/common/array.h +++ b/common/array.h @@ -63,9 +63,10 @@ public: * Constructs an array with `count` default-inserted instances of T. No * copies are made. */ - explicit Array(size_type count) : _size(0) { + explicit Array(size_type count) : _size(count) { allocCapacity(count); - resize(count); + for (size_type i = 0; i < count; ++i) + new ((void *)&_storage[i]) T(); } /** -- cgit v1.2.3