Fixed not being able to assign to bool list.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
cc86041b06
commit
97bd13a1cb
|
@ -9,6 +9,8 @@ namespace Arbutils::Collections {
|
||||||
template <class ValueT> class List {
|
template <class ValueT> class List {
|
||||||
private:
|
private:
|
||||||
std::vector<ValueT> _vector;
|
std::vector<ValueT> _vector;
|
||||||
|
using reference = typename std::vector<ValueT>::reference;
|
||||||
|
using const_reference = typename std::vector<ValueT>::const_reference;
|
||||||
using iterator = typename std::vector<ValueT>::iterator;
|
using iterator = typename std::vector<ValueT>::iterator;
|
||||||
using const_iterator = typename std::vector<ValueT>::const_iterator;
|
using const_iterator = typename std::vector<ValueT>::const_iterator;
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ namespace Arbutils::Collections {
|
||||||
|
|
||||||
inline void Clear() { _vector.clear(); }
|
inline void Clear() { _vector.clear(); }
|
||||||
|
|
||||||
inline ValueT& At(size_t index) {
|
inline reference At(size_t index) {
|
||||||
#ifndef NO_ASSERT
|
#ifndef NO_ASSERT
|
||||||
if (index >= _vector.size() || index < 0) {
|
if (index >= _vector.size() || index < 0) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -31,7 +33,7 @@ namespace Arbutils::Collections {
|
||||||
return _vector.at(index);
|
return _vector.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ValueT& At(size_t index) const {
|
inline const_reference At(size_t index) const {
|
||||||
#ifndef NO_ASSERT
|
#ifndef NO_ASSERT
|
||||||
if (index >= _vector.size() || index < 0) {
|
if (index >= _vector.size() || index < 0) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
@ -50,8 +52,8 @@ namespace Arbutils::Collections {
|
||||||
|
|
||||||
inline void Insert(size_t index, ValueT value) { _vector.insert(index, value); }
|
inline void Insert(size_t index, ValueT value) { _vector.insert(index, value); }
|
||||||
|
|
||||||
inline ValueT& operator[](size_t index) { return At(index); }
|
inline reference operator[](size_t index) { return At(index); }
|
||||||
inline const ValueT& operator[](size_t index) const { return At(index); }
|
inline const_reference operator[](size_t index) const { return At(index); }
|
||||||
|
|
||||||
inline size_t Count() const { return _vector.size(); }
|
inline size_t Count() const { return _vector.size(); }
|
||||||
inline void Resize(size_t size) { _vector.resize(size); }
|
inline void Resize(size_t size) { _vector.resize(size); }
|
||||||
|
|
|
@ -53,5 +53,13 @@ TEST_CASE("Create const List, iterate over values", "[Utilities]") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Create list of bools, assign to it", "[Utilities]") {
|
||||||
|
auto ls = List<bool>({false, false, false});
|
||||||
|
|
||||||
|
ls[1] = true;
|
||||||
|
CHECK(ls[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue