3 #include "combined/model/member.h" 5 #include "utilities/event.h" 6 #include "utilities/mapping_iterator_adapter.h" 22 vector(
size_t elements,
const T& t) {
24 for (
auto i = 0u; i != elements; ++i) {
25 data_.emplace_back(*
this, t);
29 explicit vector(
size_t elements)
34 template <
typename It>
36 reserve(std::distance(b, e));
37 std::copy(b, e, std::back_inserter(*
this));
41 explicit vector(
const T (&arr)[N])
42 : vector{std::begin(arr), std::end(arr)} {}
44 vector(
const vector& other)
45 : vector{make_item_extractor_iterator(std::begin(other)),
46 make_item_extractor_iterator(std::end(other))} {}
51 reserve(other.size());
52 std::copy(make_item_extractor_iterator(std::begin(other)),
53 make_item_extractor_iterator(std::end(other)),
54 std::back_inserter(*
this));
59 const auto& operator[](
size_t index)
const {
return data_[index]; }
60 auto& operator[](
size_t index) {
return data_[index]; }
62 auto& front() {
return data_.front(); }
63 const auto& front()
const {
return data_.front(); }
65 auto& back() {
return data_.back(); }
66 const auto& back()
const {
return data_.back(); }
68 auto cbegin()
const {
return data_.cbegin(); }
69 auto begin()
const {
return data_.begin(); }
70 auto begin() {
return data_.begin(); }
72 auto cend()
const {
return data_.cend(); }
73 auto end()
const {
return data_.end(); }
74 auto end() {
return data_.end(); }
76 void reserve(
size_t items) { data_.reserve(items); }
78 template <
typename It>
79 auto insert(It it,
const T& t) {
80 const auto i = data_.emplace(std::move(it), *
this, t);
86 data_.emplace_back(*
this, t);
95 template <
typename It>
97 const auto i = data_.erase(std::move(it));
102 void resize(
size_t new_size,
const value_type& t) {
104 while (new_size < size()) {
107 while (size() < new_size) {
112 void resize(
size_t new_size) { resize(new_size,
value_type{}); }
114 auto size()
const {
return data_.size(); }
115 auto empty()
const {
return data_.empty(); }
122 template <
typename Archive>
126 cereal::size_type size = this->size();
127 archive(cereal::make_size_tag(size));
129 for (
const auto& i : *
this) {
134 bool operator==(
const vector& x)
const {
142 [](
const auto& a,
const auto& b) {
return *a == *b; });
144 bool operator!=(
const vector& x)
const {
return !operator==(x); }
147 std::vector<data_member> data_;
vector & operator=(const vector &other)
Not strongly exception safe.
Definition: vector.h:49
Definition: capsule_base.h:9
void serialize(Archive &archive)
Definition: vector.h:123
T value_type
So that back_inserter works.
Definition: vector.h:20