@@ -25,6 +25,9 @@ IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end);
2525template <typename U, typename It, std::enable_if_t <smart_ptr_v<U>, int > = 0 >
2626IGUANA_INLINE void from_json_impl (U &value, It &&it, It &&end);
2727
28+ template <typename U, typename It, std::enable_if_t <variant_v<U>, int > = 0 >
29+ IGUANA_INLINE void from_json_impl (U &value, It &&it, It &&end);
30+
2831template <typename U, typename It,
2932 std::enable_if_t <ylt_refletable_v<U>, int > = 0 >
3033IGUANA_INLINE void from_json_impl (U &value, It &&it, It &&end) {
@@ -262,10 +265,22 @@ IGUANA_INLINE void from_json_impl(U &value, It &&it, It &&end) {
262265 }
263266}
264267
268+ template <typename T>
269+ constexpr size_t get_array_size (const T &t) {
270+ #if __cplusplus > 201703L
271+ #if __has_include(<span>)
272+ if constexpr (is_span<T>::value)
273+ return t.size ();
274+ else
275+ #endif
276+ #endif
277+ return sizeof (T) / sizeof (decltype (std::declval<T>()[0 ]));
278+ }
279+
265280template <typename U, typename It, std::enable_if_t <fixed_array_v<U>, int > = 0 >
266281IGUANA_INLINE void from_json_impl (U &value, It &&it, It &&end) {
267282 using T = std::remove_reference_t <U>;
268- constexpr auto n = sizeof (T) / sizeof ( decltype (std::declval<T>()[ 0 ]) );
283+ size_t n = get_array_size (value );
269284 skip_ws (it, end);
270285
271286 if constexpr (std::is_same_v<char , std::remove_reference_t <
@@ -546,7 +561,7 @@ IGUANA_INLINE void from_json_variant(U &value, It &it, It &end,
546561 end = temp_end;
547562}
548563
549- template <typename U, typename It, std::enable_if_t <variant_v<U>, int > = 0 >
564+ template <typename U, typename It, std::enable_if_t <variant_v<U>, int >>
550565IGUANA_INLINE void from_json_impl (U &value, It &&it, It &&end) {
551566 from_json_variant (value, it, end,
552567 std::make_index_sequence<
0 commit comments