mirror of
https://github.com/nlohmann/json.git
synced 2026-02-17 09:03:58 +00:00
♻️ allow patch and diff to be used with arbitrary string types (#4536)
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <iterator> // forward_iterator_tag
|
||||
#include <string> // string, to_string
|
||||
#include <tuple> // tuple_size, get, tuple_element
|
||||
#include <utility> // move
|
||||
|
||||
@@ -20,19 +19,13 @@
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
#include <nlohmann/detail/meta/type_traits.hpp>
|
||||
#include <nlohmann/detail/string_utils.hpp>
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename string_type>
|
||||
void int_to_string( string_type& target, std::size_t value )
|
||||
{
|
||||
// For ADL
|
||||
using std::to_string;
|
||||
target = to_string(value);
|
||||
}
|
||||
template<typename IteratorType> class iteration_proxy_value
|
||||
{
|
||||
public:
|
||||
|
||||
37
include/nlohmann/detail/string_utils.hpp
Normal file
37
include/nlohmann/detail/string_utils.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
// __ _____ _____ _____
|
||||
// __| | __| | | | JSON for Modern C++
|
||||
// | | |__ | | | | | | version 3.11.3
|
||||
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||
//
|
||||
// SPDX-FileCopyrightText: 2013 - 2024 Niels Lohmann <https://nlohmann.me>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <string> // string, to_string
|
||||
|
||||
#include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename StringType>
|
||||
void int_to_string(StringType& target, std::size_t value)
|
||||
{
|
||||
// For ADL
|
||||
using std::to_string;
|
||||
target = to_string(value);
|
||||
}
|
||||
|
||||
template<typename StringType>
|
||||
StringType to_string(std::size_t value)
|
||||
{
|
||||
StringType result;
|
||||
int_to_string(result, value);
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
NLOHMANN_JSON_NAMESPACE_END
|
||||
Reference in New Issue
Block a user