diff --git a/toml/get.hpp b/toml/get.hpp index 829ef76..8735468 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -608,8 +608,7 @@ get_or(const basic_value& v, const T& opt) { try { - return get::type>::type>(v); + return get>::type>(v); } catch(...) { @@ -624,8 +623,7 @@ get_or(basic_value& v, T& opt) { try { - return get::type>::type>(v); + return get>::type>(v); } catch(...) { @@ -634,18 +632,17 @@ get_or(basic_value& v, T& opt) } template class M, template class V> -detail::enable_if_t< - detail::is_exact_toml_type>::value, T>&& +detail::enable_if_t, + basic_value>::value, detail::remove_cvref_t> get_or(basic_value&& v, T&& opt) { try { - return get::type>::type>(v); + return get>(std::move(v)); } catch(...) { - return opt; + return detail::remove_cvref_t(std::forward(opt)); } } @@ -654,10 +651,9 @@ get_or(basic_value&& v, T&& opt) template class M, template class V> -detail::enable_if_t::type>::type, - std::string>::value, std::string> const& -get_or(const basic_value& v, T&& opt) +detail::enable_if_t, std::string>::value, + std::string> const& +get_or(const basic_value& v, const T& opt) { try { @@ -684,9 +680,8 @@ get_or(basic_value& v, T& opt) } template class M, template class V> -detail::enable_if_t::type>::type, - std::string>::value, std::string> +detail::enable_if_t< + std::is_same, std::string>::value, std::string> get_or(basic_value&& v, T&& opt) { try @@ -695,7 +690,7 @@ get_or(basic_value&& v, T&& opt) } catch(...) { - return std::forward(opt); + return std::string(std::forward(opt)); } } @@ -724,20 +719,17 @@ get_or(const basic_value& v, T&& opt) template class M, template class V> detail::enable_if_t::type>::type, + detail::negation, basic_value>>, - detail::negation::type>::type>>, + detail::negation>>, detail::negation::type>> - >::value, typename std::remove_reference::type> + >::value, detail::remove_cvref_t> get_or(const basic_value& v, T&& opt) { try { - return get::type>::type>(v); + return get>(v); } catch(...) { @@ -876,15 +868,13 @@ template::type>::type, - basic_value>>, + detail::remove_cvref_t, basic_value>>, // T is not std::string - detail::negation::type>::type>>, + detail::negation>>, // T is not a string literal detail::negation::type>> - >::value, typename std::remove_cv::type>::type> + >::value, detail::remove_cvref_t> find_or(const basic_value& v, const toml::key& ky, T&& opt) { if(!v.is_table()) {return std::forward(opt);}