You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling find_or for double or bool is ambiguous while calling for int or string works well.
#include"../toml.hpp"intmain(){
auto data = toml::parse("data.toml");
auto N = toml::find_or(data, "int", 2);
auto r = toml::find_or(data, "double", 1.0);
auto b = toml::find_or(data, "bool", true);
auto s = toml::find_or(data, "string", "foo");
}
Error message by Apple Clang is the following (GCC-9 says the similar message):
$ g++ --std=c++11 main.cpp
main.cpp:7:12: error: call to 'find_or' is ambiguous
auto r = toml::find_or(data, "double", 1.0);
^~~~~~~~~~~~~
./../toml/get.hpp:588:5: note: candidate function[with T = double, $1 = nullptr]
T&& find_or(toml::value&& v, const toml::key& ky, T&& opt)
^
./../toml/get.hpp:661:10: note: candidate function[with T = double, $1 = nullptr]
T const& find_or(const toml::table& tab, const toml::key& ky, const T& opt)
^
./../toml/get.hpp:568:10: note: candidate function[with T = double, $1 = nullptr]
T const& find_or(const toml::value& v, const toml::key& ky, const T& opt)
^
main.cpp:8:12: error: call to 'find_or' is ambiguous
auto b = toml::find_or(data, "bool", true);
^~~~~~~~~~~~~
./../toml/get.hpp:588:5: note: candidate function[with T = bool, $1 = nullptr]
T&& find_or(toml::value&& v, const toml::key& ky, T&& opt)
^
./../toml/get.hpp:661:10: note: candidate function[with T = bool, $1 = nullptr]
T const& find_or(const toml::table& tab, const toml::key& ky, const T& opt)
^
./../toml/get.hpp:568:10: note: candidate function[with T = bool, $1 = nullptr]
T const& find_or(const toml::value& v, const toml::key& ky, const T& opt)
^
2 errors generated.
Even if I declare data as toml::table explicitly, the problem still occurs.
Both the latest develop version (dee32e7) and the latest release (v2.3.1) of toml11 face this problem.
(By the way, could you put find_or into README?)
The text was updated successfully, but these errors were encountered:
I reproduced the error on my local environment. I think I understand why it is ambiguous, but currently don't have any idea to solve this without breaking the backward compatibility.
But I have one quick workaround. By receiving the result of toml::parse as a toml::value, the ambiguity would be resolved.
toml::value data = toml::parse("data.toml");
I will try to resolve this, but it takes some time...
Calling
find_or
fordouble
orbool
is ambiguous while calling forint
orstring
works well.Error message by Apple Clang is the following (GCC-9 says the similar message):
Even if I declare
data
astoml::table
explicitly, the problem still occurs.Both the latest develop version (dee32e7) and the latest release (v2.3.1) of toml11 face this problem.
(By the way, could you put
find_or
into README?)The text was updated successfully, but these errors were encountered: