diff --git a/include/cpptoml.h b/include/cpptoml.h index 5a00da3..d44c813 100644 --- a/include/cpptoml.h +++ b/include/cpptoml.h @@ -279,8 +279,8 @@ class value; template struct valid_value - : is_one_of + : is_one_of { }; @@ -455,12 +455,24 @@ struct base_type_traits static const base_type type = base_type::OFFSET_DATETIME; }; +template <> +struct base_type_traits +{ + static const base_type type = base_type::INT; +}; + template <> struct base_type_traits { static const base_type type = base_type::INT; }; +template <> +struct base_type_traits +{ + static const base_type type = base_type::FLOAT; +}; + template <> struct base_type_traits { @@ -714,6 +726,24 @@ inline std::shared_ptr> base::as() return nullptr; } +// specialization for +template <> +inline std::shared_ptr> base::as() +{ + auto v1 = as(); + auto v2 = make_value(static_cast(v1->get())); + return v2; +} + +// specialization for +template <> +inline std::shared_ptr> base::as() +{ + auto v1 = as(); + auto v2 = make_value(static_cast(v1->get())); + return v2; +} + template inline std::shared_ptr> base::as() const { @@ -760,6 +790,23 @@ inline std::shared_ptr> base::as() const return nullptr; } +template <> +inline std::shared_ptr> base::as() const +{ + auto v1 = as(); + auto v2 = make_value(static_cast(v1->get())); + return v2; +} + +// specialization for +template <> +inline std::shared_ptr> base::as() const +{ + auto v1 = as(); + auto v2 = make_value(static_cast(v1->get())); + return v2; +} + /** * Exception class for array insertion errors. */ @@ -3665,4 +3712,4 @@ inline std::ostream& operator<<(std::ostream& stream, const array& a) return stream; } } // namespace cpptoml -#endif // CPPTOML_H +#endif // CPPTOML_H \ No newline at end of file