Guarding undefined templates with a static_assert. (#1454)
* Guarding undefined templates with a static_assert. * Fixing comments. * Undeprecating (or whatever you want to call it).
This commit is contained in:
parent
92caeb039f
commit
ad37651726
|
@ -198,14 +198,6 @@ public:
|
|||
simdjson_really_inline bool is() const noexcept;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Deprecated as a public interface. These methods will be made private in a future
|
||||
* release. Use get_double(), get_bool(), get_uint64(), get_int64(),
|
||||
* get_object(), get_array() or get_string() instead. We found in practice that
|
||||
* the template would mislead users into writing get<X>() for types X that
|
||||
* are not among the supported types (e.g., get<QString>(), get<std::string>(),
|
||||
* get<short>()), and the resulting C++ compiler error is difficult to parse.
|
||||
*
|
||||
* Get the value as the provided type (T).
|
||||
*
|
||||
* Supported types:
|
||||
|
@ -215,6 +207,9 @@ public:
|
|||
* - Array: dom::array
|
||||
* - Object: dom::object
|
||||
*
|
||||
* You may use get_double(), get_bool(), get_uint64(), get_int64(),
|
||||
* get_object(), get_array() or get_string() instead.
|
||||
*
|
||||
* @tparam T bool, double, uint64_t, int64_t, std::string_view, const char *, dom::array, dom::object
|
||||
*
|
||||
* @returns The value cast to the given type, or:
|
||||
|
@ -222,7 +217,11 @@ public:
|
|||
*/
|
||||
|
||||
template<typename T>
|
||||
inline simdjson_result<T> get() const noexcept;
|
||||
inline simdjson_result<T> get() const noexcept {
|
||||
// Unless the simdjson library provides an inline implementation, calling this method should
|
||||
// immediately fail.
|
||||
static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value as the provided type (T).
|
||||
|
|
|
@ -100,24 +100,27 @@ public:
|
|||
simdjson_really_inline bool is_null() noexcept;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Deprecated as a public interface. These methods will be made private in a future
|
||||
* release. Use get_double(), get_bool(), get_uint64(), get_int64(),
|
||||
* get_object(), get_array() or get_string() instead. We found in practice that
|
||||
* the template would mislead users into writing get<X>() for types X that
|
||||
* are not among the supported types (e.g., get<QString>(), get<std::string>(),
|
||||
* get<short>()), and the resulting C++ compiler error is difficult to parse.
|
||||
*
|
||||
* Get this value as the given type.
|
||||
*
|
||||
* Supported types: object, array, raw_json_string, string_view, uint64_t, int64_t, double, bool
|
||||
*
|
||||
* You may use get_double(), get_bool(), get_uint64(), get_int64(),
|
||||
* get_object(), get_array(), get_raw_json_string(), or get_string() instead.
|
||||
*
|
||||
* @returns A value of the given type, parsed from the JSON.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not the given type.
|
||||
*/
|
||||
template<typename T> simdjson_really_inline simdjson_result<T> get() & noexcept;
|
||||
template<typename T> simdjson_really_inline simdjson_result<T> get() & noexcept {
|
||||
// Unless the simdjson library provides an inline implementation, calling this method should
|
||||
// immediately fail.
|
||||
static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library.");
|
||||
}
|
||||
/** @overload template<typename T> simdjson_result<T> get() & noexcept */
|
||||
template<typename T> simdjson_really_inline simdjson_result<T> get() && noexcept;
|
||||
template<typename T> simdjson_really_inline simdjson_result<T> get() && noexcept {
|
||||
// Unless the simdjson library provides an inline implementation, calling this method should
|
||||
// immediately fail.
|
||||
static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this value as the given type.
|
||||
|
|
|
@ -27,10 +27,17 @@ public:
|
|||
*
|
||||
* Supported types: object, array, raw_json_string, string_view, uint64_t, int64_t, double, bool
|
||||
*
|
||||
* You may use get_double(), get_bool(), get_uint64(), get_int64(),
|
||||
* get_object(), get_array(), get_raw_json_string(), or get_string() instead.
|
||||
*
|
||||
* @returns A value of the given type, parsed from the JSON.
|
||||
* @returns INCORRECT_TYPE If the JSON value is not the given type.
|
||||
*/
|
||||
template<typename T> simdjson_really_inline simdjson_result<T> get() noexcept;
|
||||
template<typename T> simdjson_really_inline simdjson_result<T> get() noexcept {
|
||||
// Unless the simdjson library provides an inline implementation, calling this method should
|
||||
// immediately fail.
|
||||
static_assert(!sizeof(T), "The get method with given type is not implemented by the simdjson library.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this value as the given type.
|
||||
|
|
Loading…
Reference in New Issue