Skip to content

parse float as integer #117

Description

@X1aomu

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions