This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.
Section: 22.7.4 [any.class] Status: C++17 Submitter: Jonathan Wakely Opened: 2016-11-09 Last modified: 2017-07-30
Priority: 0
View all other issues in [any.class].
View all issues with C++17 status.
Discussion:
Addresses US 29
What does it mean for (the contained) objects to be "equivalent"? Suggested resolution: Add definition (note that usingoperator==()
involves complicated questions of overload
resolution).
[2016-11-08, Jonathan comments and suggests wording]
We can rephrase the copy constructor in terms of equivalence to construction from the contained object. We need to use in-place construction to avoid recursion in the case where the contained object is itself an any.
For the move constructor we don't simply want to construct from the contrained object, because when the contained object is stored in dynamic memory we don't actually construct anything, we just transfer ownership of a pointer.[Issues Telecon 16-Dec-2016]
Move to Tentatively Ready
Proposed resolution:
This wording is relative to N4606.
Change [any.cons] p2:
any(const any& other);Effects:
Constructs an object of typeIfany
with an equivalent state asother
.other.has_value()
isfalse
, constructs an object that has no value. Otherwise, equivalent toany(in_place<T>, any_cast<const T&>(other))
whereT
is the type of the contained object.
Change [any.cons] p4:
any(any&& other);Effects:
Constructs an object of typeIfany
with a state equivalent to the original state ofother
.other.has_value()
isfalse
, constructs an object that has no value. Otherwise, constructs an object of typeany
that contains either the contained object ofother
, or contains an object of the same type constructed from the contained object of other considering that contained object as an rvalue.