From c0010f60e60905e8a4cbb20e290bc7129a3faae2 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Tue, 4 Aug 2020 12:48:26 -0700 Subject: [PATCH] Add view support to simdjson_result --- include/simdjson/dom/array.h | 10 ++++++++-- include/simdjson/dom/object.h | 15 +++++++++------ include/simdjson/inline/array.h | 4 ++++ include/simdjson/inline/object.h | 9 +++++++++ 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/simdjson/dom/array.h b/include/simdjson/dom/array.h index 7f8f41f3..ed42aa4a 100644 --- a/include/simdjson/dom/array.h +++ b/include/simdjson/dom/array.h @@ -177,10 +177,16 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result -namespace std::ranges { +namespace std { +namespace ranges { template<> inline constexpr bool enable_view = true; -} +#if SIMDJSON_EXCEPTIONS +template<> +inline constexpr bool enable_view> = true; +#endif // SIMDJSON_EXCEPTIONS +} // namespace ranges +} // namespace std #endif // defined(__cpp_lib_ranges) #endif // SIMDJSON_DOM_ARRAY_H diff --git a/include/simdjson/dom/object.h b/include/simdjson/dom/object.h index ed626c10..920474ab 100644 --- a/include/simdjson/dom/object.h +++ b/include/simdjson/dom/object.h @@ -284,13 +284,16 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result -namespace std::ranges { +namespace std { +namespace ranges { template<> inline constexpr bool enable_view = true; -} - -static_assert(std::ranges::view); -static_assert(std::ranges::sized_range); -#endif +#if SIMDJSON_EXCEPTIONS +template<> +inline constexpr bool enable_view> = true; +#endif // SIMDJSON_EXCEPTIONS +} // namespace ranges +} // namespace std +#endif // defined(__cpp_lib_ranges) #endif // SIMDJSON_DOM_OBJECT_H diff --git a/include/simdjson/inline/array.h b/include/simdjson/inline/array.h index 342583d4..84b5ffe1 100644 --- a/include/simdjson/inline/array.h +++ b/include/simdjson/inline/array.h @@ -174,6 +174,10 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result); static_assert(std::ranges::sized_range); +#if SIMDJSON_EXCEPTIONS +static_assert(std::ranges::view>); +static_assert(std::ranges::sized_range>); +#endif // SIMDJSON_EXCEPTIONS #endif // defined(__cpp_lib_ranges) #endif // SIMDJSON_INLINE_ARRAY_H diff --git a/include/simdjson/inline/object.h b/include/simdjson/inline/object.h index 74a05a81..425e2f1f 100644 --- a/include/simdjson/inline/object.h +++ b/include/simdjson/inline/object.h @@ -272,4 +272,13 @@ inline std::ostream& operator<<(std::ostream& out, const simdjson_result); +static_assert(std::ranges::sized_range); +#if SIMDJSON_EXCEPTIONS +static_assert(std::ranges::view>); +static_assert(std::ranges::sized_range>); +#endif // SIMDJSON_EXCEPTIONS +#endif // defined(__cpp_lib_ranges) + #endif // SIMDJSON_INLINE_OBJECT_H