diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index ffc2c4a59c..f20c91a43d 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -25,6 +25,7 @@ namespace BAN Vector() = default; Vector(Vector&&); Vector(const Vector&); + Vector(size_type, const T& = T()); ~Vector(); Vector& operator=(Vector&&); @@ -105,6 +106,8 @@ namespace BAN bool operator==(const VectorIterator& other) const { return m_data == other.m_data; } bool operator!=(const VectorIterator& other) const { return !(*this == other); } + operator bool() const { return m_data; } + private: VectorIterator(data_type* data) : m_data(data) { } @@ -138,6 +141,15 @@ namespace BAN m_size = other.m_size; } + template + Vector::Vector(size_type size, const T& value) + { + MUST(ensure_capacity(size)); + for (size_type i = 0; i < size; i++) + new (m_data + i) T(value); + m_size = size; + } + template Vector::~Vector() { @@ -381,4 +393,21 @@ namespace BAN return {}; } -} \ No newline at end of file +} + +namespace BAN::Formatter +{ + + template + void print_argument_impl(F putc, const Vector& vector, const ValueFormat& format) + { + putc('['); + for (typename Vector::size_type i = 0; i < vector.size(); i++) + { + if (i != 0) putc(','); + print_argument_impl(putc, vector[i], format); + } + putc(']'); + } + +}