The following code:
json::value params;
params[U("version")] = json::value("1.0");
results in the following JSON: `{"version":true}` under Windows, as `"1.0"` literal is implicitly converted to `bool` as it's a pointer. This is rather unfortunate and it would be nice to avoid it.
I think the simplest way to solve it would be to add a deleted ctor from narrow strings, i.e.
class value {
#ifdef _UTF16_STRINGS
value(const char*) = delete;
#endif
};
to prevent this code from compiling.
Although personally I'd be even happier if the code accept narrow strings everywhere, even under Windows, and assumed them to be in UTF-8 and did the necessary conversions transparently, this comes at a tiny performance cost but is much more user-friendly.
Comments: Why didn't Artur Laksberg's change on 2013-02-20 making value(bool) constructor explicit didn't fix this? Strange...
json::value params;
params[U("version")] = json::value("1.0");
results in the following JSON: `{"version":true}` under Windows, as `"1.0"` literal is implicitly converted to `bool` as it's a pointer. This is rather unfortunate and it would be nice to avoid it.
I think the simplest way to solve it would be to add a deleted ctor from narrow strings, i.e.
class value {
#ifdef _UTF16_STRINGS
value(const char*) = delete;
#endif
};
to prevent this code from compiling.
Although personally I'd be even happier if the code accept narrow strings everywhere, even under Windows, and assumed them to be in UTF-8 and did the necessary conversions transparently, this comes at a tiny performance cost but is much more user-friendly.
Comments: Why didn't Artur Laksberg's change on 2013-02-20 making value(bool) constructor explicit didn't fix this? Strange...