This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofResolved status.
identity<void> seems brokenSection: 22.2.4[forward]Status:ResolvedSubmitter: Walter BrownOpened: 2008-04-09Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [forward].
View all issues withResolved status.
Discussion:
N2588 seems to have added anoperator() member function to theidentity<> helper in 22.2.4[forward]. I believe this change makes it nolonger possible to instantiateidentity<void>, as it would requireforming a reference-to-void type as thisoperator()'s parameter type.
Suggested resolution: Specializeidentity<void> so as not to requirethe member function's presence.
[Sophia Antipolis:]
Jens: suggests to add a requires clause to avoid specializing on
void.Alisdair: also consider cv-qualified
void.Alberto provided proposed wording.
[2009-07-30 Daniel reopens:]
This issue became closed, because the
ReferentTyperequirementfixed the problem - this is no longer the case. In retrospective it seemsto be that the root of current issues aroundstd::identity(823,700(i),939(i))is that it was standardized as something very different (an unconditionaltype mapper) than traditional usage indicated (a function object that shouldderive fromstd::unary_function), as the SGI definition does. This issue couldbe solved, ifstd::identityis removed (one proposal of939(i)), but until thishas been decided, this issue should remain open. An alternative forremoving it, would be, to do the following:
Let
identitystay as areal function object, which wouldnow properlyderive fromunary_function:template <class T> struct identity : unary_function<T, T> { const T& operator()(const T&) const;};Invent (if needed) a generic type wrapper (corresponding to concept
IdentityOf),e.g.identity_of, and move it's prototype description back to 22.2.4[forward]:template <class T> struct identity_of { typedef T type;};and adapt the
std::forwardsignature to useidentity_ofinstead ofidentity.
[2009-10 Santa Cruz:]
Proposed resolution:
Change definition ofidentity in 22.2.4[forward], paragraph 2, to:
template <class T> struct identity { typedef T type;requires ReferentType<T> const T& operator()(const T& x) const; };...
requires ReferentType<T> const T& operator()(const T& x) const;
Rationale:
The point here is to able to writeT& givenT andReferentType isprecisely the concept that guarantees so, according to N2677(Foundational concepts). Because of this, it seems preferable than anexplicit check forcv void usingSameType/remove_cv as it was suggestedin Sophia. In particular, Daniel remarked that there may be types otherthancv void which aren't referent types (int[], perhaps?).