From 55260654bff8a42fe48b78258bbba4fd3d4aae5e Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Fri, 10 Jan 2020 20:38:52 +0900 Subject: [PATCH] feat: get user-defined value by constructor If a user-defined constructor has constructor(const toml::value&), then it should be convertible in `toml::get` and `toml::find`. --- toml/get.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/toml/get.hpp b/toml/get.hpp index ce2ea54..6418efe 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -259,6 +259,15 @@ template)> T get(const basic_value&); +// T(const toml::value&) and T is not toml::basic_value +template class M, template class V> +detail::enable_if_t>, + std::is_constructible&> + >::value, T> +get(const basic_value&); + // ============================================================================ // array-like types; most likely STL container, like std::vector, etc. @@ -417,6 +426,17 @@ T get(const basic_value& v) return ::toml::from::from_toml(v); } +template class M, template class V> +detail::enable_if_t>, + std::is_constructible&> + >::value, T> +get(const basic_value& v) +{ + return T(v); +} + // ============================================================================ // find