This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.
843. Reference ClosureSection: 99 [func.referenceclosure.cons] Status: CD1 Submitter: Lawrence Crowl Opened: 2008-06-02 Last modified: 2016-01-28
Priority: Not Prioritized
View all issues with CD1 status.
Discussion:
The std::reference_closure
type has a deleted copy assignment operator under the theory that references cannot be assigned, and hence the assignment of its reference member must necessarily be ill-formed.
However, other types, notably std::reference_wrapper
and std::function
provide for the "copying of references", and thus the current definition of std::reference_closure
seems unnecessarily restrictive. In particular, it should be possible to write generic functions using both std::function
and std::reference_closure
, but this generality is much harder when one such type does not support assignment.
The definition of reference_closure
does not necessarily imply direct implementation via reference types. Indeed, the reference_closure
is best implemented via a frame pointer, for which there is no standard type.
The semantics of assignment are effectively obtained by use of the default destructor and default copy assignment operator via
x.~reference_closure(); new (x) reference_closure(y);
So the copy assignment operator generates no significant real burden to the implementation.
Proposed resolution:
In [func.referenceclosure] Class template reference_closure, replace the =delete
in the copy assignment operator in the synopsis with =default
.
template<class R , class... ArgTypes > class reference_closure<R (ArgTypes...)> { public: ... reference_closure& operator=(const reference_closure&) = delete default; ...
In 99 [func.referenceclosure.cons] Construct, copy, destroy, add the member function description
reference_closure& operator=(const reference_closure& f)Postcondition:
*this
is a copy off
.Returns:
*this
.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4