1#if SIMDJSON_SUPPORTS_CONCEPTS
3#ifndef SIMDJSON_ONDEMAND_DESERIALIZE_H
4#ifndef SIMDJSON_CONDITIONAL_INCLUDE
5#define SIMDJSON_ONDEMAND_DESERIALIZE_H
6#include "simdjson/generic/ondemand/base.h"
7#include "simdjson/generic/ondemand/array.h"
12struct deserialize_tag;
15template <
typename>
struct is_builtin_deserializable : std::false_type {};
16template <>
struct is_builtin_deserializable<int64_t> : std::true_type {};
17template <>
struct is_builtin_deserializable<uint64_t> : std::true_type {};
18template <>
struct is_builtin_deserializable<double> : std::true_type {};
19template <>
struct is_builtin_deserializable<bool> : std::true_type {};
20template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::array> : std::true_type {};
21template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::object> : std::true_type {};
22template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::value> : std::true_type {};
23template <>
struct is_builtin_deserializable<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> : std::true_type {};
24template <>
struct is_builtin_deserializable<std::string_view> : std::true_type {};
27concept is_builtin_deserializable_v = is_builtin_deserializable<T>::value;
29template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
30concept custom_deserializable = tag_invocable<deserialize_tag, ValT&, T&>;
32template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
33concept deserializable = custom_deserializable<T, ValT> || is_builtin_deserializable_v<T> || concepts::optional_type<T>;
35template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
36concept nothrow_custom_deserializable = nothrow_tag_invocable<deserialize_tag, ValT&, T&>;
39template <
typename T,
typename ValT = SIMDJSON_IMPLEMENTATION::ondemand::value>
40concept nothrow_deserializable = nothrow_custom_deserializable<T, ValT> || is_builtin_deserializable_v<T>;
43inline constexpr struct deserialize_tag {
44 using array_type = SIMDJSON_IMPLEMENTATION::ondemand::array;
45 using object_type = SIMDJSON_IMPLEMENTATION::ondemand::object;
46 using value_type = SIMDJSON_IMPLEMENTATION::ondemand::value;
47 using document_type = SIMDJSON_IMPLEMENTATION::ondemand::document;
48 using document_reference_type = SIMDJSON_IMPLEMENTATION::ondemand::document_reference;
52 requires custom_deserializable<T, value_type>
53 simdjson_warn_unused
constexpr auto operator()(array_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, value_type>) {
54 return tag_invoke(*
this,
object, output);
59 requires custom_deserializable<T, value_type>
60 simdjson_warn_unused
constexpr auto operator()(object_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, value_type>) {
61 return tag_invoke(*
this,
object, output);
66 requires custom_deserializable<T, value_type>
67 simdjson_warn_unused
constexpr auto operator()(value_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, value_type>) {
68 return tag_invoke(*
this,
object, output);
73 requires custom_deserializable<T, document_type>
74 simdjson_warn_unused
constexpr auto operator()(document_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, document_type>) {
75 return tag_invoke(*
this,
object, output);
80 requires custom_deserializable<T, document_reference_type>
81 simdjson_warn_unused
constexpr auto operator()(document_reference_type &
object, T& output)
const noexcept(nothrow_custom_deserializable<T, document_reference_type>) {
82 return tag_invoke(*
this,
object, output);
The top level simdjson namespace, containing everything the library provides.