mirror of
https://github.com/nlohmann/json.git
synced 2026-10-21 05:28:12 +00:00
Use std::array for the index buffer in append_index()
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+8
-6
No files matched your search
@@ -9,6 +9,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm> // all_of
|
#include <algorithm> // all_of
|
||||||
|
#include <array> // array
|
||||||
#include <cctype> // isdigit
|
#include <cctype> // isdigit
|
||||||
#include <cerrno> // errno, ERANGE
|
#include <cerrno> // errno, ERANGE
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
@@ -1270,15 +1271,15 @@ class json_pointer
|
|||||||
/// append the decimal representation of @a i to @a out
|
/// append the decimal representation of @a i to @a out
|
||||||
static void append_index(string_t& out, std::size_t i)
|
static void append_index(string_t& out, std::size_t i)
|
||||||
{
|
{
|
||||||
char buf[24]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
std::array<char, 24> buf{};
|
||||||
std::size_t pos = sizeof(buf);
|
std::size_t pos = buf.size();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buf[--pos] = static_cast<char>('0' + i % 10);
|
buf[--pos] = static_cast<char>('0' + i % 10);
|
||||||
i /= 10;
|
i /= 10;
|
||||||
}
|
}
|
||||||
while (i != 0);
|
while (i != 0);
|
||||||
out.append(buf + pos, sizeof(buf) - pos);
|
out.append(buf.data() + pos, buf.size() - pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Generated
+4
-3
@@ -21427,6 +21427,7 @@ NLOHMANN_JSON_NAMESPACE_END
|
|||||||
|
|
||||||
|
|
||||||
#include <algorithm> // all_of
|
#include <algorithm> // all_of
|
||||||
|
#include <array> // array
|
||||||
#include <cctype> // isdigit
|
#include <cctype> // isdigit
|
||||||
#include <cerrno> // errno, ERANGE
|
#include <cerrno> // errno, ERANGE
|
||||||
#include <cstddef> // size_t
|
#include <cstddef> // size_t
|
||||||
@@ -22695,15 +22696,15 @@ class json_pointer
|
|||||||
/// append the decimal representation of @a i to @a out
|
/// append the decimal representation of @a i to @a out
|
||||||
static void append_index(string_t& out, std::size_t i)
|
static void append_index(string_t& out, std::size_t i)
|
||||||
{
|
{
|
||||||
char buf[24]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
std::array<char, 24> buf{};
|
||||||
std::size_t pos = sizeof(buf);
|
std::size_t pos = buf.size();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
buf[--pos] = static_cast<char>('0' + i % 10);
|
buf[--pos] = static_cast<char>('0' + i % 10);
|
||||||
i /= 10;
|
i /= 10;
|
||||||
}
|
}
|
||||||
while (i != 0);
|
while (i != 0);
|
||||||
out.append(buf + pos, sizeof(buf) - pos);
|
out.append(buf.data() + pos, buf.size() - pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|||||||
Reference in new issue
Block a user