Add view support to simdjson_result<array/object>

This commit is contained in:
John Keiser 2020-08-04 12:48:26 -07:00
parent 75301e4cf5
commit c0010f60e6
4 changed files with 30 additions and 8 deletions

View File

@ -177,10 +177,16 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result<dom::ar
#if defined(__cpp_lib_ranges)
#include <ranges>
namespace std::ranges {
namespace std {
namespace ranges {
template<>
inline constexpr bool enable_view<simdjson::dom::array> = true;
}
#if SIMDJSON_EXCEPTIONS
template<>
inline constexpr bool enable_view<simdjson::simdjson_result<simdjson::dom::array>> = true;
#endif // SIMDJSON_EXCEPTIONS
} // namespace ranges
} // namespace std
#endif // defined(__cpp_lib_ranges)
#endif // SIMDJSON_DOM_ARRAY_H

View File

@ -284,13 +284,16 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result<dom::ob
#if defined(__cpp_lib_ranges)
#include <ranges>
namespace std::ranges {
namespace std {
namespace ranges {
template<>
inline constexpr bool enable_view<simdjson::dom::object> = true;
}
static_assert(std::ranges::view<simdjson::dom::object>);
static_assert(std::ranges::sized_range<simdjson::dom::object>);
#endif
#if SIMDJSON_EXCEPTIONS
template<>
inline constexpr bool enable_view<simdjson::simdjson_result<simdjson::dom::object>> = true;
#endif // SIMDJSON_EXCEPTIONS
} // namespace ranges
} // namespace std
#endif // defined(__cpp_lib_ranges)
#endif // SIMDJSON_DOM_OBJECT_H

View File

@ -174,6 +174,10 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result<dom::ar
#if defined(__cpp_lib_ranges)
static_assert(std::ranges::view<simdjson::dom::array>);
static_assert(std::ranges::sized_range<simdjson::dom::array>);
#if SIMDJSON_EXCEPTIONS
static_assert(std::ranges::view<simdjson::simdjson_result<simdjson::dom::array>>);
static_assert(std::ranges::sized_range<simdjson::simdjson_result<simdjson::dom::array>>);
#endif // SIMDJSON_EXCEPTIONS
#endif // defined(__cpp_lib_ranges)
#endif // SIMDJSON_INLINE_ARRAY_H

View File

@ -272,4 +272,13 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result<dom::ob
} // namespace simdjson
#if defined(__cpp_lib_ranges)
static_assert(std::ranges::view<simdjson::dom::object>);
static_assert(std::ranges::sized_range<simdjson::dom::object>);
#if SIMDJSON_EXCEPTIONS
static_assert(std::ranges::view<simdjson::simdjson_result<simdjson::dom::object>>);
static_assert(std::ranges::sized_range<simdjson::simdjson_result<simdjson::dom::object>>);
#endif // SIMDJSON_EXCEPTIONS
#endif // defined(__cpp_lib_ranges)
#endif // SIMDJSON_INLINE_OBJECT_H