1
0
mirror of https://github.com/nlohmann/json synced 2024-11-29 23:21:04 +00:00

Change implementation to use templates

This commit is contained in:
Antonio Borondo 2018-10-03 11:44:02 +01:00
parent ad3c216bb5
commit 8d1585f065
2 changed files with 20 additions and 20 deletions

View File

@ -126,7 +126,7 @@ class wide_string_input_adapter : public input_adapter_protocol
// check if buffer needs to be filled
if (utf8_bytes_index == utf8_bytes_filled)
{
fill_buffer(sizeof(typename WideStringType::value_type));
fill_buffer<sizeof(typename WideStringType::value_type)>();
assert(utf8_bytes_filled > 0);
assert(utf8_bytes_index == 0);
@ -139,16 +139,16 @@ class wide_string_input_adapter : public input_adapter_protocol
}
private:
void fill_buffer(size_t size)
template<size_t T>
void fill_buffer()
{
if (2 == size)
{
fill_buffer_utf16();
}
else
{
fill_buffer_utf32();
}
fill_buffer_utf32();
}
template<>
void fill_buffer<2>()
{
fill_buffer_utf16();
}
void fill_buffer_utf16()

View File

@ -2004,7 +2004,7 @@ class wide_string_input_adapter : public input_adapter_protocol
// check if buffer needs to be filled
if (utf8_bytes_index == utf8_bytes_filled)
{
fill_buffer(sizeof(typename WideStringType::value_type));
fill_buffer<sizeof(typename WideStringType::value_type)>();
assert(utf8_bytes_filled > 0);
assert(utf8_bytes_index == 0);
@ -2017,16 +2017,16 @@ class wide_string_input_adapter : public input_adapter_protocol
}
private:
void fill_buffer(size_t size)
template<size_t T>
void fill_buffer()
{
if (2 == size)
{
fill_buffer_utf16();
}
else
{
fill_buffer_utf32();
}
fill_buffer_utf32();
}
template<>
void fill_buffer<2>()
{
fill_buffer_utf16();
}
void fill_buffer_utf16()