Skip to content

Commit 826228e

Browse files
committed
move template specializations out of class scope
1 parent 4e02630 commit 826228e

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

include/json/value.h

+34-33
Original file line numberDiff line numberDiff line change
@@ -416,39 +416,6 @@ class JSON_API Value {
416416
template <typename T> T as() const = delete;
417417
template <typename T> bool is() const = delete;
418418

419-
template <> bool as<bool>() const { return asBool(); }
420-
template <> bool is<bool>() const { return isBool(); }
421-
422-
template <> Int as<Int>() const { return asInt(); }
423-
template <> bool is<Int>() const { return isInt(); }
424-
425-
template <> UInt as<UInt>() const { return asUInt(); }
426-
template <> bool is<UInt>() const { return isUInt(); }
427-
428-
#if defined(JSON_HAS_INT64)
429-
template <> Int64 as<Int64>() const { return asInt64(); }
430-
template <> bool is<Int64>() const { return isInt64(); }
431-
432-
template <> UInt64 as<UInt64>() const { return asUInt64(); }
433-
template <> bool is<UInt64>() const { return isUInt64(); }
434-
#endif
435-
436-
template <> double as<double>() const { return asDouble(); }
437-
template <> bool is<double>() const { return isDouble(); }
438-
439-
template <> String as<String>() const { return asString(); }
440-
template <> bool is<String>() const { return isString(); }
441-
442-
/// These `as` specializations are type conversions, and do not have a
443-
/// corresponding `is`.
444-
template <> float as<float>() const { return asFloat(); }
445-
template <> const char* as<const char*>() const { return asCString(); }
446-
#ifdef JSON_USE_CPPTL
447-
template <> CppTL::ConstString as<CppTL::ConstString>() const {
448-
return asConstString();
449-
}
450-
#endif
451-
452419
bool isConvertibleTo(ValueType other) const;
453420

454421
/// Number of values in array or object
@@ -710,6 +677,40 @@ class JSON_API Value {
710677
ptrdiff_t limit_;
711678
};
712679

680+
template <> inline bool Value::as<bool>() const { return asBool(); }
681+
template <> inline bool Value::is<bool>() const { return isBool(); }
682+
683+
template <> inline Int Value::as<Int>() const { return asInt(); }
684+
template <> inline bool Value::is<Int>() const { return isInt(); }
685+
686+
template <> inline UInt Value::as<UInt>() const { return asUInt(); }
687+
template <> inline bool Value::is<UInt>() const { return isUInt(); }
688+
689+
#if defined(JSON_HAS_INT64)
690+
template <> inline Int64 Value::as<Int64>() const { return asInt64(); }
691+
template <> inline bool Value::is<Int64>() const { return isInt64(); }
692+
693+
template <> inline UInt64 Value::as<UInt64>() const { return asUInt64(); }
694+
template <> inline bool Value::is<UInt64>() const { return isUInt64(); }
695+
#endif
696+
697+
template <> inline double Value::as<double>() const { return asDouble(); }
698+
template <> inline bool Value::is<double>() const { return isDouble(); }
699+
700+
template <> inline String Value::as<String>() const { return asString(); }
701+
template <> inline bool Value::is<String>() const { return isString(); }
702+
703+
/// These `as` specializations are type conversions, and do not have a
704+
/// corresponding `is`.
705+
template <> inline float Value::as<float>() const { return asFloat(); }
706+
template <> inline const char* Value::as<const char*>() const { return asCString(); }
707+
#ifdef JSON_USE_CPPTL
708+
template <> inline CppTL::ConstString Value::as<CppTL::ConstString>() const {
709+
return asConstString();
710+
}
711+
#endif
712+
713+
713714
/** \brief Experimental and untested: represents an element of the "path" to
714715
* access a node.
715716
*/

0 commit comments

Comments
 (0)