cpptoml
cpptoml copied to clipboard
parse float as integer
Given the follow toml:
[default]
size = 9.0 # This should be integer, but it was given a float accidently
And the parsing code:
constexpr size_t kDefaultSize = 3;
auto defaultSize = _config->get_qualified_as<size_t>("default.size").value_or(kDefaultSize);
cout << defautSize << endl;
Here we get the output:
3
Currently, it just act like that the key defaut.size
is never present in the toml file, and then it finally get the default value. But, it does present, which confusing me a lot.
I know there exists a type mismatch. However, I think, in this case, it should either throw an exception to report that conversion couldn't be made or just cut the dicimal part out (9.0 -> 9 in this example).