|
@@ -21,7 +21,12 @@ public:
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- explicit Vector(int n) : Vector(n, T()) {
|
|
+ explicit Vector(int n) : Vector() {
|
|
|
|
+ // calling Vector(n, T()) would break structures which can be
|
|
|
|
+ // default constructed but not copied e.g. unique pointers elements
|
|
|
|
+ for(int i = 0; i < n; i++) {
|
|
|
|
+ push_back(T());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
~Vector() {
|
|
~Vector() {
|
|
@@ -90,8 +95,8 @@ public:
|
|
|
|
|
|
void resize(int size) {
|
|
void resize(int size) {
|
|
// calling resize(size, T()); would break structures which can be
|
|
// calling resize(size, T()); would break structures which can be
|
|
- // default constructed but not copied e.g. unique pointers elements will
|
|
+ // default constructed but not copied e.g. unique pointers elements
|
|
- // be equal to size after this call but not the capacity
|
|
+ // will be equal to size after this call but not the capacity
|
|
if(size > elements) {
|
|
if(size > elements) {
|
|
// fill until the given size is reached
|
|
// fill until the given size is reached
|
|
for(int i = elements; i < size; i++) {
|
|
for(int i = elements; i < size; i++) {
|