55 if constexpr (std::is_same_v<T, std::atomic_flag>) {
56 current() = (it.test() ?
"SET" :
"CLEAR");
57 }
else if constexpr (packtl::is_type<std::unique_ptr, T>::value) {
58 const auto* value = it.get();
61 }
else if constexpr (packtl::is_type<std::shared_ptr, T>::value) {
63 const auto* value = it.get();
67 current() =
"reference";
70 }
else if constexpr (packtl::is_type<std::weak_ptr, T>::value) {
75 const auto* value = it.get();
79 current() =
"reference";
83 if (visited_.contains((std::size_t)&it)) {
84 out <<
"<circular reference>";
87 visited_.emplace((std::size_t)&it);
88 }
else if constexpr (std::is_convertible_v<T, std::string>) {
89 current() = std::format(
"{}", std::string{it});
90 }
else if constexpr (std::same_as<T, char*>) {
91 current() = std::format(
"{}", std::string{it});
93 }
else if constexpr (std::same_as<T, const char*>) {
94 current() = std::format(
"{}", std::string{it});
96 }
else if constexpr (std::same_as<T, int> or std::same_as<T, unsigned int> or
97 std::same_as<T, short> or std::same_as<T, unsigned short> or
98 std::same_as<T, long> or std::same_as<T, unsigned long> or
99 std::same_as<T, float> or std::same_as<T, double>) {
101 }
else if constexpr (std::same_as<T, bool>) {
102 current() = std::format(
"{}", it ?
"true" :
"false");
103 }
else if constexpr (std::formattable<T, char>) {
104 current() = std::format(
"{}", it);
112 if constexpr (std::__is_std_pair<typename T::value_type>) {
113 using type =
typename T::value_type;
114 if constexpr (std::same_as<typename type::first_type, std::string> or
115 std::same_as<typename type::first_type, const std::string>) {
116 current() = JSON::object({});
117 for (
const auto& [first, second]: iterable) {
118 current()[first] =
JSON{};
119 push(current()[first]);
126 current() = JSON::array({});
166 std::string field_name = Field::name;
167 if constexpr (Field::template has_metadata<serialize::name>) {
168 field_name = Field::template get_metadata<serialize::name>.value;
172 if constexpr (Field::template has_metadata<serialize::policy::policy_e>) {
173 current_policy = Field::template get_metadata<serialize::policy::policy_e>;
174 if constexpr (Field::template get_metadata<serialize::policy::policy_e> ==
176 current()[field_name] =
JSON{};
177 push(current()[field_name]);
179 if constexpr (Field::is_reference) {
180 const auto& it = Field::from_instance(obj);
182 }
else if constexpr (Field::is_pointer) {
183 const auto* it = Field::from_instance(obj);
186 const auto& it = Field::from_instance(obj);
191 }
else if constexpr (Field::template get_metadata<serialize::policy::policy_e> ==
193 current()[field_name] =
JSON{};
194 push(current()[field_name]);
196 if constexpr (Field::is_reference) {
197 current() =
"reference";
198 }
else if constexpr (Field::is_pointer) {
199 current() =
"reference";
201 const auto& it = Field::from_instance(obj);
206 }
else if constexpr (Field::template get_metadata<serialize::policy::policy_e> ==
211 current()[field_name] =
JSON{};
212 push(current()[field_name]);