@@ -62,12 +62,12 @@ class tag_array final : public detail::crtp_tag<tag_array<T>>
62
62
tag_array () {}
63
63
64
64
// /Constructs an array with the given values
65
- tag_array (std::initializer_list<T> init);
66
- tag_array (std::vector<T>&& vec) noexcept ;
65
+ tag_array (std::initializer_list<T> init): data(init) {}
66
+ tag_array (std::vector<T>&& vec) noexcept : data(std::move(vec)) {}
67
67
68
68
// /Returns a reference to the vector that contains the values
69
- std::vector<T>& get ();
70
- const std::vector<T>& get () const ;
69
+ std::vector<T>& get () { return data; }
70
+ const std::vector<T>& get () const { return data; }
71
71
72
72
/* *
73
73
* @brief Accesses a value by index with bounds checking
@@ -81,20 +81,20 @@ class tag_array final : public detail::crtp_tag<tag_array<T>>
81
81
*
82
82
* No bounds checking is performed.
83
83
*/
84
- T& operator [](size_t i);
85
- T operator [](size_t i) const ;
84
+ T& operator [](size_t i) { return data[i]; }
85
+ T operator [](size_t i) const { return data[i]; }
86
86
87
87
// /Appends a value at the end of the array
88
- void push_back (T val);
88
+ void push_back (T val) { data. push_back (val); }
89
89
90
90
// /Removes the last element from the array
91
- void pop_back ();
91
+ void pop_back () { data. pop_back (); }
92
92
93
93
// /Returns the number of values in the array
94
- size_t size () const ;
94
+ size_t size () const { return data. size (); }
95
95
96
96
// /Erases all values from the array.
97
- void clear ();
97
+ void clear () { data. clear (); }
98
98
99
99
// Iterators
100
100
iterator begin ();
@@ -115,8 +115,10 @@ class tag_array final : public detail::crtp_tag<tag_array<T>>
115
115
std::vector<T> data;
116
116
};
117
117
118
- template <class T > bool operator ==(const tag_array<T>& lhs, const tag_array<T>& rhs);
119
- template <class T > bool operator !=(const tag_array<T>& lhs, const tag_array<T>& rhs);
118
+ template <class T > bool operator ==(const tag_array<T>& lhs, const tag_array<T>& rhs)
119
+ { return lhs.get () == rhs.get (); }
120
+ template <class T > bool operator !=(const tag_array<T>& lhs, const tag_array<T>& rhs)
121
+ { return !(lhs == rhs); }
120
122
121
123
// Typedefs that should be used instead of the template tag_array.
122
124
typedef tag_array<int8_t > tag_byte_array;
0 commit comments