diff --git a/include/json/value.h b/include/json/value.h index 2f5bfc5..3435a18 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -416,39 +416,6 @@ public: template T as() const = delete; template bool is() const = delete; - template <> bool as() const { return asBool(); } - template <> bool is() const { return isBool(); } - - template <> Int as() const { return asInt(); } - template <> bool is() const { return isInt(); } - - template <> UInt as() const { return asUInt(); } - template <> bool is() const { return isUInt(); } - -#if defined(JSON_HAS_INT64) - template <> Int64 as() const { return asInt64(); } - template <> bool is() const { return isInt64(); } - - template <> UInt64 as() const { return asUInt64(); } - template <> bool is() const { return isUInt64(); } -#endif - - template <> double as() const { return asDouble(); } - template <> bool is() const { return isDouble(); } - - template <> String as() const { return asString(); } - template <> bool is() const { return isString(); } - - /// These `as` specializations are type conversions, and do not have a - /// corresponding `is`. - template <> float as() const { return asFloat(); } - template <> const char* as() const { return asCString(); } -#ifdef JSON_USE_CPPTL - template <> CppTL::ConstString as() const { - return asConstString(); - } -#endif - bool isConvertibleTo(ValueType other) const; /// Number of values in array or object @@ -710,6 +677,40 @@ private: ptrdiff_t limit_; }; +template <> inline bool Value::as() const { return asBool(); } +template <> inline bool Value::is() const { return isBool(); } + +template <> inline Int Value::as() const { return asInt(); } +template <> inline bool Value::is() const { return isInt(); } + +template <> inline UInt Value::as() const { return asUInt(); } +template <> inline bool Value::is() const { return isUInt(); } + +#if defined(JSON_HAS_INT64) +template <> inline Int64 Value::as() const { return asInt64(); } +template <> inline bool Value::is() const { return isInt64(); } + +template <> inline UInt64 Value::as() const { return asUInt64(); } +template <> inline bool Value::is() const { return isUInt64(); } +#endif + +template <> inline double Value::as() const { return asDouble(); } +template <> inline bool Value::is() const { return isDouble(); } + +template <> inline String Value::as() const { return asString(); } +template <> inline bool Value::is() const { return isString(); } + +/// These `as` specializations are type conversions, and do not have a +/// corresponding `is`. +template <> inline float Value::as() const { return asFloat(); } +template <> inline const char* Value::as() const { return asCString(); } +#ifdef JSON_USE_CPPTL +template <> inline CppTL::ConstString Value::as() const { + return asConstString(); +} +#endif + + /** \brief Experimental and untested: represents an element of the "path" to * access a node. */