3 #include "combined/model/vector.h" 10 template <
typename T,
size_t MinSize>
12 :
public owning_member<min_size_vector<T, MinSize>, vector<T>> {
19 :
base_type{vector<T>{MinSize + extra, t}} {}
30 static_assert(MinSize <= N,
31 "Must be at least MinSize elements in initializer list.");
36 bool can_erase()
const {
return MinSize < size(); }
40 const auto& operator[](
size_t index)
const {
return vec()[index]; }
41 auto& operator[](
size_t index) {
return vec()[index]; }
43 auto& front() {
return vec().front(); }
44 const auto& front()
const {
return vec().front(); }
46 auto& back() {
return vec().back(); }
47 const auto& back()
const {
return vec().back(); }
49 auto cbegin()
const {
return vec().cbegin(); }
50 auto begin()
const {
return vec().begin(); }
51 auto begin() {
return vec().begin(); }
53 auto cend()
const {
return vec().cend(); }
54 auto end()
const {
return vec().end(); }
55 auto end() {
return vec().end(); }
57 void reserve(
size_t items) { vec().reserve(items); }
59 template <
typename It>
60 auto insert(It it,
const T& t) {
61 return vec().insert(std::move(it), t);
64 void push_back(
const T& t) { vec().push_back(t); }
66 void pop_back() { vec().pop_back(); }
70 template <
typename It>
73 vec().erase(std::move(it));
78 void resize(
size_t new_size,
const T& t) {
79 vec().resize(std::max(MinSize, new_size), t);
84 auto size()
const {
return vec().size(); }
85 auto empty()
const {
return vec().empty(); }
87 void clear() { vec().clear(); }
89 NOTIFYING_COPY_ASSIGN_DECLARATION(min_size_vector)
91 inline void swap(min_size_vector&) noexcept {
using std::swap; };
93 auto& vec() {
return *this->
template get<0>(); }
94 const auto& vec()
const {
return *this->
template get<0>(); }
void resize(size_t new_size, const T &t)
Will resize to std::max(MinSize, new_size)
Definition: min_size_vector.h:78
Definition: capsule_base.h:9
A vector which must hold some minimum number of elements.
Definition: min_size_vector.h:11
min_size_vector(size_t extra, const T &t)
Definition: min_size_vector.h:18