mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:28:12 +08:00
feat: update expect for basic_value
This commit is contained in:
22
toml/get.hpp
22
toml/get.hpp
@@ -865,12 +865,14 @@ T find_or(const toml::table& tab, const toml::key& ky, T&& opt)
|
|||||||
if(tab.count(ky) == 0) {return opt;}
|
if(tab.count(ky) == 0) {return opt;}
|
||||||
return get_or(tab.at(ky), std::forward<T>(opt));
|
return get_or(tab.at(ky), std::forward<T>(opt));
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// expect
|
// expect
|
||||||
|
|
||||||
template<typename T>
|
template<typename T, typename C,
|
||||||
result<T, std::string> expect(const toml::value& v) noexcept
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
|
result<T, std::string> expect(const basic_value<C, M, V>& v) noexcept
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -881,8 +883,10 @@ result<T, std::string> expect(const toml::value& v) noexcept
|
|||||||
return err(e.what());
|
return err(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T, typename C,
|
||||||
result<T, std::string> expect(const toml::value& v, const toml::key& k) noexcept
|
template<typename ...> class M, template<typename ...> class V>
|
||||||
|
result<T, std::string>
|
||||||
|
expect(const basic_value<C, M, V>& v, const toml::key& k) noexcept
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -893,9 +897,12 @@ result<T, std::string> expect(const toml::value& v, const toml::key& k) noexcept
|
|||||||
return err(e.what());
|
return err(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T, typename Table>
|
||||||
result<T, std::string> expect(const toml::table& t, const toml::key& k,
|
enable_if_t<detail::conjunction<
|
||||||
std::string tablename = "unknown table") noexcept
|
detail::is_map<Table>, detail::is_basic_value<typename Table::mapped_type>
|
||||||
|
>::value, result<T, std::string>>
|
||||||
|
expect(const Table& t, const toml::key& k,
|
||||||
|
std::string tablename = "unknown table") noexcept
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -906,6 +913,5 @@ result<T, std::string> expect(const toml::table& t, const toml::key& k,
|
|||||||
return err(e.what());
|
return err(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
} // toml
|
} // toml
|
||||||
#endif// TOML11_GET
|
#endif// TOML11_GET
|
||||||
|
Reference in New Issue
Block a user