Skip to content

Commit

Permalink
Change implementation to use templates
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Borondo committed Oct 3, 2018
1 parent ad3c216 commit 8d1585f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
20 changes: 10 additions & 10 deletions include/nlohmann/detail/input/input_adapters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand Down
20 changes: 10 additions & 10 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -2017,18 +2017,18 @@ 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()
{
utf8_bytes_index = 0;
Expand Down

0 comments on commit 8d1585f

Please sign in to comment.