Skip to content

Commit def726f

Browse files
committed
Fix signed char char traits
1 parent 24e9f2d commit def726f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

include/nlohmann/detail/input/input_adapters.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ template<>
162162
struct char_traits<signed char> : std::char_traits<char>
163163
{
164164
using char_type = signed char;
165+
using int_type = unsigned long;
166+
167+
// Redefine to_int_type function
168+
static int_type to_int_type(char_type c)
169+
{
170+
return static_cast<int_type>(c);
171+
}
172+
173+
static int_type eof()
174+
{
175+
return static_cast<int_type>(EOF);
176+
}
165177
};
166178

167179
// General-purpose iterator-based adapter. It might not be as fast as

single_include/nlohmann/json.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -6239,6 +6239,18 @@ template<>
62396239
struct char_traits<signed char> : std::char_traits<char>
62406240
{
62416241
using char_type = signed char;
6242+
using int_type = unsigned long;
6243+
6244+
// Redefine to_int_type function
6245+
static int_type to_int_type(char_type c)
6246+
{
6247+
return static_cast<int_type>(c);
6248+
}
6249+
6250+
static int_type eof()
6251+
{
6252+
return static_cast<int_type>(EOF);
6253+
}
62426254
};
62436255

62446256
// General-purpose iterator-based adapter. It might not be as fast as

0 commit comments

Comments
 (0)