Commit 93bb7123 by Nikita Ofitserov

Move from rvalues eagerly to work around MSVC problem

On MSVC compiler, temporaries that are constructed during a list initialization, are sometimes destroyed even before calling the initializing constructor, instead of at the end of the containing full-expression. This is clearly non-conforming to [class.temporary]. As the impact of this bug is silently producing incorrect JSON values, move eagerly from rvalues to be safe. See https://stackoverflow.com/questions/24586411
parent 897879bc
...@@ -7088,9 +7088,11 @@ struct json_ref ...@@ -7088,9 +7088,11 @@ struct json_ref
typedef BasicJsonType value_type; typedef BasicJsonType value_type;
json_ref(value_type&& value) json_ref(value_type&& value)
: value_ref_(&value) : owned_value_(std::move(value))
, is_rvalue_(true) , is_rvalue_(true)
{} {
value_ref_ = &owned_value_;
}
json_ref(const value_type& value) json_ref(const value_type& value)
: value_ref_(const_cast<value_type*>(&value)) : value_ref_(const_cast<value_type*>(&value))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment