Skip to content

Commit f709997

Browse files
committed
Fixed SSE Windows string parsing
1 parent 4673bde commit f709997

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

cpr/sse.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "cpr/sse.h"
22

33
#include <charconv>
4-
#include <utility>
54
#include <cstddef>
65
#include <functional>
76
#include <string>
87
#include <string_view>
98
#include <system_error>
9+
#include <utility>
1010

1111
namespace cpr {
1212

@@ -87,7 +87,9 @@ bool ServerSentEventParser::processLine(const std::string& line, const std::func
8787
// Parse retry value as integer
8888
size_t retry_value = 0;
8989
const std::string_view sv(value);
90-
auto [ptr, ec] = std::from_chars(sv.begin(), sv.end(), retry_value);
90+
const char* begin = sv.data();
91+
const char* end = begin + sv.size(); // NOLINT (cppcoreguidelines-pro-bounds-pointer-arithmetic) Required here since Windows and Clang/GCC have different std::string_view iterator implementations
92+
auto [ptr, ec] = std::from_chars(begin, end, retry_value);
9193
if (ec == std::errc()) {
9294
current_event_.retry = retry_value;
9395
}

0 commit comments

Comments
 (0)