Skip to content

Commit 721fa4e

Browse files
Improve compatibility with various STL flavors
In our STL std::string::iterator is not a class but rather a raw pointer. Suggested approach works as std::advance [accepts](https://en.cppreference.com/w/cpp/iterator/advance) Distance type as a template parameter.
1 parent 542fcf7 commit 721fa4e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/protozero/buffer_string.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ struct buffer_customization<std::string> {
5757
protozero_assert(from <= buffer->size());
5858
protozero_assert(to <= buffer->size());
5959
protozero_assert(from <= to);
60-
buffer->erase(std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(from)),
61-
std::next(buffer->begin(), static_cast<std::string::iterator::difference_type>(to)));
60+
buffer->erase(std::advance(buffer->begin(), from),
61+
std::advance(buffer->begin(), to));
6262
}
6363

6464
static char* at_pos(std::string* buffer, std::size_t pos) {

0 commit comments

Comments
 (0)