Title
any_cast and move semantics
Status
c++17
Section
[any.nonmembers]
Submitter
Casey Carter

Created on 2016-08-27.00:00:00 last changed 89 months ago

Messages

Date: 2016-12-16.21:09:36

Proposed resolution:

Resolved by the wording provided by LWG 2769.

Date: 2017-02-02.00:41:18

[ Issues Telecon 16-Dec-2016 ]

Move to Tentatively Ready

Date: 2016-09-09.00:00:00

[ 2016-09-09 Issues Resolution Telecon ]

P0; move to Tentatively Ready

Previous resolution [SUPERSEDED]:

This wording is relative to N4606.

  1. In [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> is true or is_copy_constructible_v<ValueType> is true. Otherwise the program is ill-formed.

    -5- Returns: For the first form, *any_cast<add_const_t<remove_reference_t<ValueType>>>(&operand). For the second and third forms, *any_cast<remove_reference_t<ValueType>>(&operand). For the third form, std::forward<ValueType>(*any_cast<remove_reference_t<ValueType>>(&operand)).

    […]

Date: 2016-08-27.00:00:00

LWG 2509 made two changes to the specification of any in v2 of the library fundamentals TS:

  1. It altered the effects of the any_cast(any&&) overload to enable moving the value out of the any object and/or obtaining an rvalue reference to the contained value.
  2. It made changes to support pathological copyable-but-not-movable contained values, which is madness.

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.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2017-03-05 23:41:16adminsetstatus: ready -> wp
2016-12-16 21:09:36adminsetmessages: + msg8754
2016-12-16 21:09:36adminsetstatus: open -> ready
2016-11-14 03:53:34adminsetstatus: ready -> open
2016-09-12 04:36:33adminsetmessages: + msg8509
2016-09-12 04:36:33adminsetstatus: new -> ready
2016-09-05 18:03:29adminsetmessages: + msg8493
2016-08-27 00:00:00admincreate