This commit is contained in:
nlohmann
2026-07-11 13:21:47 +00:00
parent 0a9a593da9
commit 483310ef04
269 changed files with 427 additions and 347 deletions
File diff suppressed because one or more lines are too long
+13 -5
View File
@@ -10,8 +10,8 @@ static basic_json parse(InputType&& i,
const bool ignore_trailing_commas = false);
// (2)
template<typename IteratorType>
static basic_json parse(IteratorType first, IteratorType last,
template<typename IteratorType, typename SentinelType = IteratorType>
static basic_json parse(IteratorType first, SentinelType last,
const parser_callback_t cb = nullptr,
const bool allow_exceptions = true,
const bool ignore_comments = false,
@@ -20,9 +20,9 @@ static basic_json parse(IteratorType first, IteratorType last,
1. Deserialize from a compatible input.
1. Deserialize from a pair of character iterators
1. Deserialize from a pair of character iterators, or an iterator and a sentinel of a different type (C++20 ranges support)
The `value_type` of the iterator must be an integral type with size of 1, 2, or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16, and UTF-32.
The `value_type` of the iterator must be an integral type with size of 1, 2, or 4 bytes, which will be interpreted respectively as UTF-8, UTF-16, and UTF-32. If `SentinelType` differs from `IteratorType`, it must be comparable to the iterator type with `operator!=`.
## Template parameters
@@ -45,6 +45,13 @@ static basic_json parse(IteratorType first, IteratorType last,
- a pair of pointers such as `ptr` and `ptr + len`
```
`SentinelType` : defaults to `IteratorType`; may be a different type comparable to `IteratorType` via `operator!=`, for instance.
```
- a custom sentinel type for C++20 ranges
- `std::counted_iterator` with a different sentinel type
```
## Parameters
`i` (in) : Input to parse from.
@@ -59,7 +66,7 @@ static basic_json parse(IteratorType first, IteratorType last,
`first` (in) : iterator to the start of a character range
`last` (in) : iterator to the end of a character range
`last` (in) : iterator to the end of a character range, or a sentinel value that compares equal to the end iterator with `operator!=`
## Return value
@@ -618,6 +625,7 @@ Output:
- Changed [runtime assertion](https://json.nlohmann.me/features/assertions/index.md) in case of `FILE*` null pointers to exception in version 3.12.0.
- Added `ignore_trailing_commas` in version 3.13.0.
- Extended container support (1) to include types with lvalue-only ADL `begin`/`end` (matching `std::begin`/`std::end` semantics) in version 3.13.0.
- Extended overload (2) to accept heterogeneous iterator+sentinel pairs (C++20 ranges support) in version 3.13.0.
Deprecation