🔀 Merge branch 'master' into v3

This commit is contained in:
ToruNiina
2019-06-15 15:17:08 +09:00
3 changed files with 9 additions and 7 deletions

View File

@@ -1170,6 +1170,8 @@ I appreciate the help of the contributors who introduced the great feature to th
- Fixed warnings on MSVC - Fixed warnings on MSVC
- Ivan Shynkarenka (@chronoxor) - Ivan Shynkarenka (@chronoxor)
- Fixed Visual Studio 2019 warnings - Fixed Visual Studio 2019 warnings
- @khoitd1997
- Fixed warnings while type conversion
## Licensing terms ## Licensing terms

View File

@@ -45,7 +45,7 @@ inline std::string show_char(const char c)
buf.fill('\0'); buf.fill('\0');
const auto r = std::snprintf( const auto r = std::snprintf(
buf.data(), buf.size(), "0x%02x", static_cast<int>(c) & 0xFF); buf.data(), buf.size(), "0x%02x", static_cast<int>(c) & 0xFF);
assert(r == buf.size() - 1); assert(r == static_cast<int>(buf.size()) - 1);
return std::string(buf.data()); return std::string(buf.data());
} }
} }

View File

@@ -713,7 +713,7 @@ get_or(basic_value<C, M, V>&& v, T&& opt)
} }
catch(...) catch(...)
{ {
return std::string(opt); return std::forward<T>(opt);
} }
} }
@@ -829,10 +829,10 @@ template<typename T, typename C,
detail::enable_if_t<std::is_same<T, std::string>::value, std::string> detail::enable_if_t<std::is_same<T, std::string>::value, std::string>
find_or(basic_value<C, M, V>&& v, const toml::key& ky, T&& opt) find_or(basic_value<C, M, V>&& v, const toml::key& ky, T&& opt)
{ {
if(!v.is_table()) {return opt;} if(!v.is_table()) {return std::forward<T>(opt);}
auto tab = std::move(v).as_table(); auto tab = toml::get<toml::table>(std::move(v));
if(tab.count(ky) == 0) {return opt;} if(tab.count(ky) == 0) {return std::forward<T>(opt);}
return get_or(std::move(tab.at(ky)), std::forward<T>(opt)); return get_or(std::move(tab[ky]), std::forward<T>(opt));
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -934,7 +934,7 @@ detail::enable_if_t<detail::conjunction<
>::value, std::string> >::value, std::string>
find_or(Table&& tab, const key& ky, T&& opt) find_or(Table&& tab, const key& ky, T&& opt)
{ {
if(tab.count(ky) == 0) {return opt;} if(tab.count(ky) == 0) {return std::forward<T>(opt);}
return get_or(std::move(tab[ky]), std::forward<T>(opt)); return get_or(std::move(tab[ky]), std::forward<T>(opt));
} }