diff --git a/README.md b/README.md index b890733..b7a6d58 100644 --- a/README.md +++ b/README.md @@ -1170,6 +1170,8 @@ I appreciate the help of the contributors who introduced the great feature to th - Fixed warnings on MSVC - Ivan Shynkarenka (@chronoxor) - Fixed Visual Studio 2019 warnings +- @khoitd1997 + - Fixed warnings while type conversion ## Licensing terms diff --git a/toml/combinator.hpp b/toml/combinator.hpp index 9f9fa9c..1c6ce25 100644 --- a/toml/combinator.hpp +++ b/toml/combinator.hpp @@ -45,7 +45,7 @@ inline std::string show_char(const char c) buf.fill('\0'); const auto r = std::snprintf( buf.data(), buf.size(), "0x%02x", static_cast(c) & 0xFF); - assert(r == buf.size() - 1); + assert(r == static_cast(buf.size()) - 1); return std::string(buf.data()); } } diff --git a/toml/get.hpp b/toml/get.hpp index 40f4a93..bbc9a09 100644 --- a/toml/get.hpp +++ b/toml/get.hpp @@ -713,7 +713,7 @@ get_or(basic_value&& v, T&& opt) } catch(...) { - return std::string(opt); + return std::forward(opt); } } @@ -829,10 +829,10 @@ template::value, std::string> find_or(basic_value&& v, const toml::key& ky, T&& opt) { - if(!v.is_table()) {return opt;} - auto tab = std::move(v).as_table(); - if(tab.count(ky) == 0) {return opt;} - return get_or(std::move(tab.at(ky)), std::forward(opt)); + if(!v.is_table()) {return std::forward(opt);} + auto tab = toml::get(std::move(v)); + if(tab.count(ky) == 0) {return std::forward(opt);} + return get_or(std::move(tab[ky]), std::forward(opt)); } // --------------------------------------------------------------------------- @@ -934,7 +934,7 @@ detail::enable_if_t::value, std::string> find_or(Table&& tab, const 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)); }