Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit 92896a2

Browse files
committed
string_view: add assert for operator[]
1 parent 51cb8af commit 92896a2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/libpmemobj++/string_view.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LIBPMEMOBJ_CPP_STRING_VIEW
1111

1212
#include <algorithm>
13+
#include <cassert>
1314
#include <string>
1415

1516
#if __cpp_lib_string_view
@@ -161,6 +162,7 @@ template <typename CharT, typename Traits>
161162
inline const CharT &basic_string_view<CharT, Traits>::operator[](size_t p) const
162163
noexcept
163164
{
165+
assert(p < size());
164166
return data()[p];
165167
}
166168

0 commit comments

Comments
 (0)