mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-17 16:51:33 -04:00
Let a vector be constructed from initializer list
This commit is contained in:
parent
72b68463a4
commit
270648b447
@ -8,6 +8,8 @@
|
|||||||
#ifndef VECTOR_H
|
#ifndef VECTOR_H
|
||||||
#define VECTOR_H
|
#define VECTOR_H
|
||||||
|
|
||||||
|
#include <initializer_list>
|
||||||
|
|
||||||
#include <types.hpp>
|
#include <types.hpp>
|
||||||
#include <algorithms.hpp>
|
#include <algorithms.hpp>
|
||||||
#include <new.hpp>
|
#include <new.hpp>
|
||||||
@ -32,8 +34,13 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
vector() : data(nullptr), _size(0), _capacity(0) {}
|
vector() : data(nullptr), _size(0), _capacity(0) {}
|
||||||
|
|
||||||
explicit vector(uint64_t c) : data(new T[c]), _size(0), _capacity(c) {}
|
explicit vector(uint64_t c) : data(new T[c]), _size(0), _capacity(c) {}
|
||||||
|
|
||||||
|
vector(initializer_list<T> values) : data(new T[values.size()]), _size(values.size()), _capacity(values.size()) {
|
||||||
|
std::copy(values.begin(), values.end(), begin());
|
||||||
|
}
|
||||||
|
|
||||||
vector(const vector& rhs) : data(nullptr), _size(rhs._size), _capacity(rhs._capacity) {
|
vector(const vector& rhs) : data(nullptr), _size(rhs._size), _capacity(rhs._capacity) {
|
||||||
if(!rhs.empty()){
|
if(!rhs.empty()){
|
||||||
data = new T[_capacity];
|
data = new T[_capacity];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user