fix assertion messages for bounded_vector::back() method

master
Francisco 4 years ago committed by Andre Puschmann
parent 5cce2e4dc7
commit 7ee99a529a

@ -101,8 +101,16 @@ public:
assert(i < size_ && "Array index is out of bounds."); assert(i < size_ && "Array index is out of bounds.");
return reinterpret_cast<const T&>(buffer[i]); return reinterpret_cast<const T&>(buffer[i]);
} }
T& back() { return (*this)[size_ - 1]; } T& back()
const T& back() const { return (*this)[size_ - 1]; } {
assert(size_ > 0 && "Trying to get back of empty array.");
return *(begin() + size_ - 1);
}
const T& back() const
{
assert(size_ > 0 && "Trying to get back of empty array.");
return *(begin() + size_ - 1);
}
T& front() { return (*this)[0]; } T& front() { return (*this)[0]; }
const T& front() const { return (*this)[0]; } const T& front() const { return (*this)[0]; }
T* data() { return reinterpret_cast<T*>(&buffer[0]); } T* data() { return reinterpret_cast<T*>(&buffer[0]); }

Loading…
Cancel
Save