-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
json becomes empty for unknown reason #2470
Comments
What is empty here, |
If changing from
to
makes it work, then you likely have another |
No, I mean that if I copy this function, rename copied one to something different, and use it, then it will work as expected. If I just rename For example, this function is used in multiple files, and template<typename T>
T import_0(const nlohmann::json &config) { But this used only in one file, and it will work as expected template<typename T>
T import_1(const nlohmann::json &config) { Also, these functions located in the unique namespace, so, I cannot use other function instead of Moreover, if I put struct JsonHelper {
nlohmann::json json;
JsonHelper(nlohmann::json inJson);
}
JsonHelper::JsonHelper(nlohmann::json inJson)
: json(move(inJson))
{
// see initializer list above
} then the
Code: JsonHelper jh = json {1.0f, 2.0f, 3.0f};
//cout << jh.json.dump() << "\n"; // [1.0,2.0,3.0]
vec3 v = GLMTransferrer::import<vec3>(jh); // GLMTransferrer - just namespace But if I uncomment 2nd line JsonHelper jh = json {1.0f, 2.0f, 3.0f};
cout << jh.json.dump() << "\n"; // [1.0,2.0,3.0]
vec3 v = GLMTransferrer::import<vec3>(jh); then will be different exception:
and template<typename T>
T import(const JsonHelper &jsonHelper) {
const auto &config = jsonHelper.json;
printf("%i\n", config.size()); // prints 1 I really don't understand what the black magic is going on, looks like a compiler bug. |
Can you provide a self-contained minimal code example? |
Problem solved. I noticed, that in all source files except one was template<typename T>
T import(const std::string &config) { |
It is a really strange issue: when I pass
nlohmann::json
to function it (json) becomes empty for an unknown reason. Moreover, if I just copy this function and rename it, everything ok.Code below uses
glm
. It is in a separate header that is included in others.Example:
What is the expected behavior?
config
mustn't be emptyAnd what is the actual behavior instead?
config
for unknown reason becomes emptyWhich compiler and operating system are you using?
Which version of the library did you use?
develop
branchThe text was updated successfully, but these errors were encountered: