diff --git a/toml/find.hpp b/toml/find.hpp index 5291546..1f8ed02 100644 --- a/toml/find.hpp +++ b/toml/find.hpp @@ -41,7 +41,7 @@ template class M, template class V> basic_value&& find(basic_value&& v, const key& ky) { - auto& tab = v.template cast(); + auto tab = std::move(v).as_table(); if(tab.count(ky) == 0) { throw std::out_of_range(detail::format_underline(concat_to_string( @@ -60,7 +60,7 @@ template(std::declval const&>())) find(const basic_value& v, const key& ky) { - const auto& tab = v.template cast(); + const auto& tab = v.as_table(); if(tab.count(ky) == 0) { throw std::out_of_range(detail::format_underline(concat_to_string( @@ -76,7 +76,7 @@ template(std::declval&>())) find(basic_value& v, const key& ky) { - auto& tab = v.template cast(); + auto& tab = v.as_table(); if(tab.count(ky) == 0) { throw std::out_of_range(detail::format_underline(concat_to_string( @@ -92,7 +92,7 @@ template(std::declval&&>())) find(basic_value&& v, const key& ky) { - auto& tab = v.template cast(); + auto tab = std::move(v).as_table(); if(tab.count(ky) == 0) { throw std::out_of_range(detail::format_underline(concat_to_string( @@ -193,9 +193,9 @@ template find_or(basic_value&& v, const toml::key& ky, basic_value&& opt) { - if(!v.is_table()) {return opt;} + if(!v.is_table()) {return std::move(opt);} auto tab = std::move(v).as_table(); - if(tab.count(ky) == 0) {return opt;} + if(tab.count(ky) == 0) {return std::move(opt);} return std::move(tab[ky]); } @@ -231,9 +231,9 @@ detail::enable_if_t< detail::is_exact_toml_type>::value, T>&& find_or(basic_value&& v, const toml::key& ky, T&& opt) { - if(!v.is_table()) {return opt;} + if(!v.is_table()) {return std::forward(opt);} auto tab = std::move(v).as_table(); - if(tab.count(ky) == 0) {return opt;} + if(tab.count(ky) == 0) {return std::forward(opt);} return get_or(std::move(tab[ky]), std::forward(opt)); }