Address array and vector storage through .data()
When used like &vec[0], there would be an assert in gnu std lib: /usr/include/c++/8/bits/stl_vector.h:932: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = char; _Alloc = std::allocator<char>; std::vector<_Tp, _Alloc>::reference = char&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed. on the other hand, using .data() is allowed even on empty uninited vectors array<> access is modified for consistency.
Showing
Please register or sign in to comment