revert recursive find function

I found that in a user-code (I'm also one of the users of this library),
this new feature sometimes causes an error. Some of my code won't
compile because of this change. Since toml::table is convertible to
toml::value *implicitly*, if toml::find(table, key, tablename) was
called, the overload resolution becomes ambiguous with toml::find(
value, key1, key2). But dropping support for toml::find(toml::table,
key, tablename) is a breaking change. So I concluded that now is not
the right time yet.
This commit is contained in:
ToruNiina
2019-06-16 19:52:59 +09:00
parent b2daf916b3
commit cbaaaaca7c
3 changed files with 20 additions and 172 deletions

View File

@@ -430,32 +430,6 @@ find(toml::value&& v, const toml::key& ky)
return ::toml::get<T>(std::move(tab[ky]));
}
// --------------------------------------------------------------------------
// toml::find(toml::value, toml::key, Ts&& ... keys)
//
// Note: C++ draft N3337 (14.1.11) says that...
// > If a template-parameter of a class template or alias template has a default
// > template-argument, each subsequent template-parameter shall either have a
// > default template-argument supplied or be a template parameter pack.
// So the template parameter pack can appear after a default template argument.
template<typename T = ::toml::value, typename ... Ts>
decltype(::toml::get<T>(std::declval<const ::toml::value&>()))
find(const ::toml::value& v, const ::toml::key& ky, Ts&& ... keys)
{
return ::toml::find<T>(::toml::find(v, ky), std::forward<Ts>(keys)...);
}
template<typename T = ::toml::value, typename ... Ts>
decltype(::toml::get<T>(std::declval<::toml::value&>()))
find(::toml::value& v, const ::toml::key& ky, Ts&& ... keys)
{
return ::toml::find<T>(::toml::find(v, ky), std::forward<Ts>(keys)...);
}
template<typename T = ::toml::value, typename ... Ts>
decltype(::toml::get<T>(std::declval<::toml::value&&>()))
find(::toml::value&& v, const ::toml::key& ky, Ts&& ... keys)
{
return ::toml::find<T>(::toml::find(std::move(v), ky), std::forward<Ts>(keys)...);
}
// ============================================================================
// get_or(value, fallback)