marzer/tomlplusplus

Use of overloaded operator '=' is ambiguous (with operand types 'toml::table' and 'toml::parse_result')

zzztttkkk opened this issue · 4 comments

Environment

toml++ version and/or commit hash:
3.1.0 via vcpkg

Compiler:
vs 2022 17.3.2; clion

C++ standard mode:
20

Target arch:
x64

Describe the bug

It compiles and runs successfully, but the ide report a error. I do not why.
This may be an ide problem, thanks.

Steps to reproduce (or a small repro code sample)

I also trying like this, but it can not be compiled.

auto result = toml::parse_file(fielpath);
if(result.failed()){
    ...
}
...

Additional information

screen_image

Ok, I'm confused. toml::parse_result is only a separate type when you're using exceptions, otherwise it's an alias for toml::table. If you're seeing it as a concrete type, then you have exceptions disabled, right? If you have them disabled, why are you doing try/catch in that screenshot? Something doesn't make sense here.

To be clear:

Using toml++ with Exceptions enabled:

toml::table tbl;
try
{
	tbl = toml::parse_file(some_path);
	// use your table
}
catch (const toml::parse_error& exc)
{
	// handle the error
}

Using toml++ with Exceptions disabled:

toml::parse_result result = toml::parse_file(some_path);
if (!result)
{
	// handle the error
}
else
{
	toml::table tbl = std::move(result);
	// use your table
}

Only one of these will compile, depending on your settings.

If you haven't disabled exceptions and are definitelly correct in using try/catch, then it's probably just your IDE being a bit confused. You can probably fix that by explicitly setting TOML_EXCEPTIONS to 1 somewhere before you include toml.h.

after #define TOML_EXCEPTIONS 1, It compiles and runs successfully, but the ide still report a error.

so it must be a ide bug, i can ignore it.

thanks.