any_cast
and move semanticsSection: 22.7.5 [any.nonmembers] Status: C++17 Submitter: Casey Carter Opened: 2016-08-27 Last modified: 2017-07-30
Priority: 0
View all other issues in [any.nonmembers].
View all issues with C++17 status.
Discussion:
LWG 2509 made two changes to the specification of any
in v2 of the library fundamentals TS:
any_cast(any&&)
overload to enable moving the value out of the any
object and/or obtaining an rvalue reference to the contained value.
Change 1 has very desirable effects; I propose that we apply the sane part of LWG 2509 to any
in the C++17 WP, for all of the reasons cited in the discussion of LWG 2509.
[2016-09-09 Issues Resolution Telecon]
P0; move to Tentatively Ready
Previous resolution [SUPERSEDED]:
This wording is relative to N4606.
In 22.7.5 [any.nonmembers] p5, edit as follows:
template<class ValueType> ValueType any_cast(const any& operand); template<class ValueType> ValueType any_cast(any& operand); template<class ValueType> ValueType any_cast(any&& operand);-4- Requires:
is_reference_v<ValueType>
istrue
oris_copy_constructible_v<ValueType>
istrue
. Otherwise the program is ill-formed.-5- Returns: For the first form,
*any_cast<add_const_t<remove_reference_t<ValueType>>>(&operand)
. For the secondand thirdforms,*any_cast<remove_reference_t<ValueType>>(&operand)
. For the third form,std::forward<ValueType>(*any_cast<remove_reference_t<ValueType>>(&operand))
.[…]
[Issues Telecon 16-Dec-2016]
Move to Tentatively Ready
Proposed resolution:
Resolved by the wording provided by LWG 2769.