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
Perhaps I should mention that int is used for the sake of clarity, and that it's replaced with a custom type in my use-case. Nonetheless, v1 compiles while v2 does not. Using v2 = j.get<decltype(v2)>(); solves the problem, albeit not that compact. I suspect this has to do with overloads from std initialisation(?)
Indeed, this happens when T has multiple operator= definitions. I don't think we can do anything about it, I personally always use get in such cases.
We should add an entry to the documentation explaining why this issue exists.
The feature is quite convenient, but code breaks when someone adds an operator= to a class.
By the way, there is no need to add from_json method for std::vector and STL-types, the library already implement those (not to mention that your method will never be called by the library).
Activity
mlund commentedon Jul 27, 2017
Perhaps I should mention that
intis used for the sake of clarity, and that it's replaced with a custom type in my use-case. Nonetheless,v1compiles whilev2does not. Usingv2 = j.get<decltype(v2)>();solves the problem, albeit not that compact. I suspect this has to do with overloads fromstdinitialisation(?)nlohmann commentedon Jul 30, 2017
I can reproduce this with clang version 6.0.0 (trunk 309129):
nlohmann commentedon Jul 30, 2017
I hope @theodelrieu can help here.
theodelrieu commentedon Aug 1, 2017
Indeed, this happens when
Thas multipleoperator=definitions. I don't think we can do anything about it, I personally always usegetin such cases.We should add an entry to the documentation explaining why this issue exists.
The feature is quite convenient, but code breaks when someone adds an
operator=to a class.theodelrieu commentedon Aug 12, 2017
By the way, there is no need to add
from_jsonmethod forstd::vectorand STL-types, the library already implement those (not to mention that your method will never be called by the library).📝 added note wrt. #667
nlohmann commentedon Aug 15, 2017
Updated the documentation.