Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::string in an extra-properties.yaml #25

Open
brandonkimbk opened this issue Jul 24, 2020 · 0 comments
Open

std::string in an extra-properties.yaml #25

brandonkimbk opened this issue Jul 24, 2020 · 0 comments

Comments

@brandonkimbk
Copy link

Even though std::string is part of the supported types of Value std::variant, it's deceivingly hard to use.

I was running into this issue: https://stackoverflow.com/questions/44086269/why-does-my-variant-convert-a-stdstring-to-a-bool where:
"The type of "hello" is const char [6], which decays to const char *. The conversion from const char * to bool is a built-in conversion, while the conversion from const char * to std::string is a user-defined conversion, which means the former is performed."

The fix was to declare the string using a Folded Block Scalar > and then wrapping the string in std::string("hello") for example.

A comment / documentation somewhere of this behavior may be useful as this is not very obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant