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
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.
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: