@@ -25,45 +25,45 @@ template <typename T, size_t CAPACITY> class FixedVector {
25
25
constexpr FixedVector () = default;
26
26
27
27
using iterator = typename cpp::array<T, CAPACITY>::iterator;
28
- constexpr FixedVector (iterator begin, iterator end) {
28
+ constexpr FixedVector (iterator begin, iterator end) : store{}, item_count{} {
29
29
for (; begin != end; ++begin)
30
30
push_back (*begin);
31
31
}
32
32
33
- constexpr FixedVector (size_t count, const T &value) {
33
+ constexpr FixedVector (size_t count, const T &value) : store{}, item_count{} {
34
34
for (size_t i = 0 ; i < count; ++i)
35
35
push_back (value);
36
36
}
37
37
38
- bool push_back (const T &obj) {
38
+ constexpr bool push_back (const T &obj) {
39
39
if (item_count == CAPACITY)
40
40
return false ;
41
41
store[item_count] = obj;
42
42
++item_count;
43
43
return true ;
44
44
}
45
45
46
- const T &back () const { return store[item_count - 1 ]; }
46
+ constexpr const T &back () const { return store[item_count - 1 ]; }
47
47
48
- T &back () { return store[item_count - 1 ]; }
48
+ constexpr T &back () { return store[item_count - 1 ]; }
49
49
50
- bool pop_back () {
50
+ constexpr bool pop_back () {
51
51
if (item_count == 0 )
52
52
return false ;
53
53
--item_count;
54
54
return true ;
55
55
}
56
56
57
- T &operator [](size_t idx) { return store[idx]; }
57
+ constexpr T &operator [](size_t idx) { return store[idx]; }
58
58
59
- const T &operator [](size_t idx) const { return store[idx]; }
59
+ constexpr const T &operator [](size_t idx) const { return store[idx]; }
60
60
61
- bool empty () const { return item_count == 0 ; }
61
+ constexpr bool empty () const { return item_count == 0 ; }
62
62
63
- size_t size () const { return item_count; }
63
+ constexpr size_t size () const { return item_count; }
64
64
65
65
// Empties the store for all practical purposes.
66
- void reset () { item_count = 0 ; }
66
+ constexpr void reset () { item_count = 0 ; }
67
67
68
68
// This static method does not free up the resources held by |store|,
69
69
// say by calling `free` or something similar. It just does the equivalent
0 commit comments