From 5e480b56d843f3dd6869c2f7bbaeec1788076ac5 Mon Sep 17 00:00:00 2001 From: Perry Kundert Date: Fri, 6 Oct 2017 07:37:49 -0700 Subject: [PATCH] Further simplify character type handling --- src/json.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/json.hpp b/src/json.hpp index 5fc467da..e3231f7d 100644 --- a/src/json.hpp +++ b/src/json.hpp @@ -1451,9 +1451,12 @@ class input_stream_adapter : public input_adapter_protocol input_stream_adapter(const input_stream_adapter&) = delete; input_stream_adapter& operator=(input_stream_adapter&) = delete; + // std::istream/std::streambuf use std::char_traits::to_int_type, to + // ensure that std::char_traits::eof() and the character 0xff do not + // end up as the same value, eg. 0xffffffff. int get_character() override { - return reinterpret_cast( sb->sbumpc() ); + return sb->sbumpc(); } void unget_character() override @@ -1489,10 +1492,10 @@ class input_buffer_adapter : public input_adapter_protocol { if (JSON_LIKELY(cursor < limit)) { - return reinterpret_cast(std::char_traits::to_int_type(*(cursor++))); + return std::char_traits::to_int_type(*(cursor++)); } - return reinterpret_cast(std::char_traits::eof()); + return std::char_traits::eof(); } void unget_character() noexcept override