diff options
author | Ben Woosley <ben.woosley@gmail.com> | 2018-09-19 02:02:12 -0400 |
---|---|---|
committer | Ben Woosley <ben.woosley@gmail.com> | 2018-09-19 02:02:12 -0400 |
commit | d2eee87928781ab3082d4279aa6f19641a45e801 (patch) | |
tree | 254722d3929197381cc968555b8405823f920f59 /src | |
parent | d26278988fbfc71dc558f7b2c60a184e8091450b (diff) |
Lift prevector default vals to the member declaration
Diffstat (limited to 'src')
-rw-r--r-- | src/prevector.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/prevector.h b/src/prevector.h index 6ddb6f321f..24831848b5 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -148,14 +148,14 @@ public: }; private: - size_type _size; + size_type _size = 0; union direct_or_indirect { char direct[sizeof(T) * N]; struct { size_type capacity; char* indirect; }; - } _union; + } _union = {}; T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; } const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; } @@ -246,34 +246,34 @@ public: fill(item_ptr(0), first, last); } - prevector() : _size(0), _union{{}} {} + prevector() {} - explicit prevector(size_type n) : prevector() { + explicit prevector(size_type n) { resize(n); } - explicit prevector(size_type n, const T& val) : prevector() { + explicit prevector(size_type n, const T& val) { change_capacity(n); _size += n; fill(item_ptr(0), n, val); } template<typename InputIterator> - prevector(InputIterator first, InputIterator last) : prevector() { + prevector(InputIterator first, InputIterator last) { size_type n = last - first; change_capacity(n); _size += n; fill(item_ptr(0), first, last); } - prevector(const prevector<N, T, Size, Diff>& other) : prevector() { + prevector(const prevector<N, T, Size, Diff>& other) { size_type n = other.size(); change_capacity(n); _size += n; fill(item_ptr(0), other.begin(), other.end()); } - prevector(prevector<N, T, Size, Diff>&& other) : prevector() { + prevector(prevector<N, T, Size, Diff>&& other) { swap(other); } |