From 89b376b4df41956d171a3280c7fd0f8c45210b0d Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Wed, 26 Mar 2025 23:54:00 +0900 Subject: [PATCH] fix: disambiguate overload for optional --- include/toml11/find.hpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/include/toml11/find.hpp b/include/toml11/find.hpp index d1f70bb..428aaf6 100644 --- a/include/toml11/find.hpp +++ b/include/toml11/find.hpp @@ -17,21 +17,24 @@ namespace toml // find(value, key); template -decltype(::toml::get(std::declval const&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval const&>()))> find(const basic_value& v, const typename basic_value::key_type& ky) { return ::toml::get(v.at(ky)); } template -decltype(::toml::get(std::declval&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&>()))> find(basic_value& v, const typename basic_value::key_type& ky) { return ::toml::get(v.at(ky)); } template -decltype(::toml::get(std::declval&&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&&>()))> find(basic_value&& v, const typename basic_value::key_type& ky) { return ::toml::get(std::move(v.at(ky))); @@ -41,19 +44,22 @@ find(basic_value&& v, const typename basic_value::key_type& ky) // find(value, idx) template -decltype(::toml::get(std::declval const&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval const&>()))> find(const basic_value& v, const std::size_t idx) { return ::toml::get(v.at(idx)); } template -decltype(::toml::get(std::declval&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&>()))> find(basic_value& v, const std::size_t idx) { return ::toml::get(v.at(idx)); } template -decltype(::toml::get(std::declval&&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&&>()))> find(basic_value&& v, const std::size_t idx) { return ::toml::get(std::move(v.at(idx))); @@ -262,19 +268,22 @@ find(basic_value&& v, const K1& k1, const K2& k2, const Ks& ... ks) // find(v, keys...) template -decltype(::toml::get(std::declval&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&>()))> find(const basic_value& v, const K1& k1, const K2& k2, const Ks& ... ks) { return find(v.at(detail::key_cast(k1)), detail::key_cast(k2), ks...); } template -decltype(::toml::get(std::declval&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&>()))> find(basic_value& v, const K1& k1, const K2& k2, const Ks& ... ks) { return find(v.at(detail::key_cast(k1)), detail::key_cast(k2), ks...); } template -decltype(::toml::get(std::declval&&>())) +cxx::enable_if_t>::value, + decltype(::toml::get(std::declval&&>()))> find(basic_value&& v, const K1& k1, const K2& k2, const Ks& ... ks) { return find(std::move(v.at(detail::key_cast(k1))), detail::key_cast(k2), ks...);