json_view: address review of the exception diagnostics

- value_path(): check for the empty stack where the last frame is popped,
  so that the loop is `for (;;)`; update the frame only after the target
  check; document that the frame reference is not used after pop_back()
  or push_back() (and add a test with deep documents to run under a
  sanitizer)
- value_range(): flip the container check to remove a level of nesting
- diagnostics(): wrap the whole function in the macro check, and compute
  the path before the bytes, so that nothing is computed when there is no
  path; the function stays a template
- error_site: separate constructors for the two configurations
- site_of(): static_assert that it is called with a view
- document why the throw helpers without an error_site have none
- pointer.hpp: do not split a comment around the template header
- docs: "when materialize() sets them"; list the effects of
  JSON_DIAGNOSTICS and JSON_DIAGNOSTIC_POSITIONS separately

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Claude authored and Niels Lohmann committed 2026-10-31 14:01:50 +01:00
1 parent 7b74ef0b3e
commit 8dd6c6aca1
12 files changed
+180 -139

No files matched your search

+1 -1
View File
@@ -44,8 +44,8 @@ index_status array_index(const StringType& s, std::size_t& idx) noexcept
}
/// throws the exception json_pointer::array_index throws for this status
template<typename StringType>
/// (without a context, as json_pointer::array_index)
template<typename StringType>
[[noreturn]] NLOHMANN_VIEW_NOINLINE void throw_array_index_error(index_status status, const StringType& s)
{
switch (status)