| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
PR #2786 added dom::element::get_u8string(). This extends the same idea to the On-Demand API and makes std::u8string_view / std::u8string first-class types in get<T>(). New accessors (all zero-copy aliases of their char-based counterparts, since every string simdjson produces is valid UTF-8): * ondemand::value::get_u8string(bool allow_replacement = false) * ondemand::document / document_reference::get_u8string(...) * ondemand::field::unescaped_u8key(...) and escaped_u8key() * the matching simdjson_result<> forwarders Type-based access: * get<std::u8string_view>() on ondemand::value, ondemand::document, ondemand::document_reference and dom::element (which also gives dom::element::get(std::u8string_view&) and is<std::u8string_view>()) * get<std::u8string>() and containers/optionals of it through the C++20 deserialization path (new concepts::constructible_from_u8string_view) * get_string(receiver) and unescaped_key(receiver) now accept a std::u8string or std::u8string_view receiver The new SIMDJSON_SUPPORTS_CHAR8_T macro replaces the raw __cpp_char8_t feature test that PR #2786 repeated at each call site. Nothing is added when char8_t is unavailable, so C++11/14/17 builds are unaffected. get_wobbly_string() deliberately has no u8 variant: wobbly strings may be invalid UTF-8 (WTF-8), so they do not belong in a std::u8string_view. Claude-Session: https://claude.ai/code/session_01EKoa1vNn8ZKwJH4qaZTU2M
Under -DSIMDJSON_STATIC_REFLECTION_MODE=ON, std::u8string is a class type with no reflectable members, so user_defined_type<T> accepted it and the reflected-struct tag_invoke overload competed with the new u8 string overload. Every tag_invoke call on std::u8string was therefore ambiguous, custom_deserializable<std::u8string> was false, and get<std::u8string>() (and any container of it) failed the static_assert in value.h. std::string and std::string_view were already excluded by name for the same reason; this adds their char8_t counterparts, guarded by SIMDJSON_SUPPORTS_CHAR8_T so nothing changes for C++17 and earlier. The gcc 16 job builds with static reflection on, which is why this only showed up there: ondemand_u8string_tests passes in every other configuration. Claude-Session: https://claude.ai/code/session_01K1fw1eGejVLMVvHjAFD8CU
| Back | FazBrowse Home | New Git URL |
Short title (summary): Add C++20 char8_t string accessors to the On-Demand API
Description
PR #2786 added get_u8string() to dom::element. This PR extends the same idea to the On-Demand API, and makes std::u8string_view and std::u8string first-class types in get<T>() on both APIs. Closes #2731.
Every string simdjson produces is valid UTF-8, so all of the new accessors are zero-copy aliases of their char-based counterparts: the same bytes, at the same address, no conversion.
New accessors
Type-based access
Notes
Type of change
How to verify / test
Checklist before submitting
https://claude.ai/code/session_01EKoa1vNn8ZKwJH4qaZTU2M