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
{{ message }}
Repository navigation
In basic_json::basic_json(const CompatibleArrayType& val), the requirement of CompatibleArrayType is not strict enough. #174
This is a question Ralated to #167 :
In basic_json::basic_json(const CompatibleArrayType& val), the requirement of CompatibleArrayType is not strict enough.
Template constructor of basic_json_t above can receive any type that has a type member value_type which can be used as the only parameter in one of basic_json_t's constructors and regard that type as a CompatibleArrayType.
I think the scope of the target types is too much wide, though it excludes some of the types already meet the requirement but are not CompatibleArrayType, still not fine with 3rd party types.
Simply define a type whose value_type is basic_json< xxx > will break the functionality, in which case a wrong conversion will be defined and unless you define a operator<< (or anything basic_json has) for that type, otherwise calling a operator<< will instantialize the conversion constructor ending with a compiling error.
Activity
nlohmann commentedon Jan 10, 2016
The code was inspired by some similar constructor from dropbox/json11. In fact, I only added constraints to make the code compile in my setting.
@mysyljr, do you have an example where the code actually breaks?
jasper412 commentedon Jan 11, 2016
Simply define a type whose value_type is basic_json< xxx > will break the functionality, in which case a wrong conversion will be defined and unless you define a operator<< (or anything basic_json has) for that type, otherwise calling a operator<< will instantialize the conversion constructor ending with a compiling error.
nlohmann commentedon Jan 20, 2016
I do not really see the need to change the library's code nor how a change would look like...
nlohmann commentedon Jan 26, 2016
@mysyljr Sorry, I really need an actual example to proceed here.