From 43907de3654820907a3d3b0ff98fcaba229bb284 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sat, 31 Aug 2019 17:28:07 +0900 Subject: [PATCH] refactor: check key types in find(v, k1, k2, ...) ks should be convertible to toml::key --- toml/find.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/toml/find.hpp b/toml/find.hpp index 6399e2c..5291546 100644 --- a/toml/find.hpp +++ b/toml/find.hpp @@ -109,7 +109,8 @@ find(basic_value&& v, const key& ky) template class M, template class V, typename ... Ts> -const basic_value& +detail::enable_if_t... + >::value, const basic_value&> find(const basic_value& v, const ::toml::key& ky, Ts&& ... keys) { return ::toml::find(::toml::find(v, ky), std::forward(keys)...); @@ -117,7 +118,8 @@ find(const basic_value& v, const ::toml::key& ky, Ts&& ... keys) template class M, template class V, typename ... Ts> -basic_value& +detail::enable_if_t... + >::value, basic_value&> find(basic_value& v, const ::toml::key& ky, Ts&& ... keys) { return ::toml::find(::toml::find(v, ky), std::forward(keys)...); @@ -125,7 +127,8 @@ find(basic_value& v, const ::toml::key& ky, Ts&& ... keys) template class M, template class V, typename ... Ts> -basic_value&& +detail::enable_if_t... + >::value, basic_value&&> find(basic_value&& v, const ::toml::key& ky, Ts&& ... keys) { return ::toml::find(::toml::find(std::move(v), ky), std::forward(keys)...); @@ -134,7 +137,8 @@ find(basic_value&& v, const ::toml::key& ky, Ts&& ... keys) template class M, template class V, typename ... Ts> -decltype(::toml::get(std::declval&>())) +detail::enable_if_t... + >::value, decltype(get(std::declval&>()))> find(const basic_value& v, const ::toml::key& ky, Ts&& ... keys) { return ::toml::find(::toml::find(v, ky), std::forward(keys)...); @@ -142,7 +146,8 @@ find(const basic_value& v, const ::toml::key& ky, Ts&& ... keys) template class M, template class V, typename ... Ts> -decltype(::toml::get(std::declval&>())) +detail::enable_if_t... + >::value, decltype(get(std::declval&>()))> find(basic_value& v, const ::toml::key& ky, Ts&& ... keys) { return ::toml::find(::toml::find(v, ky), std::forward(keys)...); @@ -150,7 +155,8 @@ find(basic_value& v, const ::toml::key& ky, Ts&& ... keys) template class M, template class V, typename ... Ts> -decltype(::toml::get(std::declval&&>())) +detail::enable_if_t... + >::value, decltype(get(std::declval&&>()))> find(basic_value&& v, const ::toml::key& ky, Ts&& ... keys) { return ::toml::find(::toml::find(std::move(v), ky), std::forward(keys)...);