diff --git a/toml/get.hpp b/toml/get.hpp index 326f2a9..fb2f403 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -545,7 +545,7 @@ std::string get_or(toml::value&& v, T&& opt) } catch(...) { - return opt; + return std::forward(opt); } } template::value, std::nullptr_t>::type = nullptr> std::string find_or(toml::value&& v, const toml::key& ky, T&& opt) { - if(!v.is_table()) {return opt;} + if(!v.is_table()) {return std::forward(opt);} auto tab = toml::get(std::move(v)); - 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)); } @@ -726,7 +726,7 @@ template::value, std::nullptr_t>::type = nullptr> std::string find_or(toml::table&& tab, const toml::key& ky, T&& opt) { - 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)); }