Commit Graph
7 Commits
Author SHA1 Message Date
Nikita Ofitserov 93bb71232d 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
2017-07-25 12:17:32 +03:00
Nikita Ofitserov 897879bccb Make detail::json_ref do less work by deferring moves/copies 2017-07-24 12:29:06 +03:00
Nikita Ofitserov 0f4978e503 Fix an actually invalid test
C++ overload resolution/list initialization rules are hard.
2017-07-24 01:08:33 +03:00
Nikita Ofitserov f5cae64e52 Update tests while fixing possible UB
std::initializer_list does not own the temporaries created in
its initialization. Therefore, storing it in an independent
stack variable is unsafe.
2017-07-23 23:59:34 +03:00
Nikita Ofitserov 09cda57309 Support moving from rvalues in an std::initializer_list
This commit works around an issue in std::initializer_list design.
By using a detail::json_ref proxy with a mutable value inside,
rvalue-ness of an input to list initializer is remembered and
used later to move from the proxy instead of copying.
2017-07-23 23:57:17 +03:00
Nikita Ofitserov cf3ca3b78c Optimize json construction from rvalue string_t/array_t/object_t 2017-07-23 23:50:59 +03:00
Nikita Ofitserov 7b3cbfff23 Add some tests for std::move from std::initializer_list 2017-07-23 23:47:15 +03:00