-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Templated accessors and range-based for #542
Conversation
|
||
template<typename ValueType> | ||
struct TypeHelper<ValueType, typename ValueType::Array> { | ||
typedef typename ValueType::Array ArratType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here: ArratType?
👍 LGTM, thanks! I haven't seen a conversion from |
There are
Maybe a (move) constructor and assignment will be more complete. |
Yes, but no GenericValue(Object o) : RAPIDJSON_NOEXCEPT : data_(), flags_(kNullFlag) {
RAPIDJSON_ASSERT(o.ptr_);
RawAssign(*o.ptr_);
o.ptr_->SetObject(); // maintain invariant
} |
GenericValue& SetArray() { this->~GenericValue(); new (this) GenericValue(kArrayType); return *this; } | ||
|
||
//! Set this value with an array. | ||
GenericValue& SetArray(Array& a) { return *this = *a.ptr_; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this call, a.ptr_
is null, not an (empty) array. We should add an a.ptr_->SetArray();
here (set for SetObject(Object);` to avoid breaking the invariant.
Secondly, we should check for a.ptr_ not being NULL in an assert, which could happen due to a default constructed Array|Object
instance.
Templated accessors and range-based for
Thank you @pah |
Fix #316, #162, #212
Request for code review