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
This commit is contained in:
parent
897879bccb
commit
93bb71232d
1 changed files with 4 additions and 2 deletions
|
@ -7088,9 +7088,11 @@ struct json_ref
|
|||
typedef BasicJsonType value_type;
|
||||
|
||||
json_ref(value_type&& value)
|
||||
: value_ref_(&value)
|
||||
: owned_value_(std::move(value))
|
||||
, is_rvalue_(true)
|
||||
{}
|
||||
{
|
||||
value_ref_ = &owned_value_;
|
||||
}
|
||||
|
||||
json_ref(const value_type& value)
|
||||
: value_ref_(const_cast<value_type*>(&value))
|
||||
|
|
Loading…
Reference in a new issue