This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++11 status.
INVOKE on member data pointer with too many argumentsSection: 22.10.4 [func.require] Status: C++11 Submitter: Howard Hinnant Opened: 2010-10-10 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [func.require].
View all other issues in [func.require].
View all issues with C++11 status.
Discussion:
20.8.2 [func.require] p1 says:
1 Define
INVOKE(f, t1, t2, ..., tN)as follows:
(t1.*f)(t2, ..., tN)whenfis a pointer to a member function of a classTandt1is an object of typeTor a reference to an object of typeTor a reference to an object of a type derived fromT;((*t1).*f)(t2, ..., tN)whenfis a pointer to a member function of a classTandt1is not one of the types described in the previous item;t1.*fwhenfis a pointer to member data of a classTandt1is an object of typeTor a reference to an object of typeTor a reference to an object of a type derived fromT;(*t1).*fwhenfis a pointer to member data of a classTandt1is not one of the types described in the previous item;f(t1, t2, ..., tN)in all other cases.
The question is: What happens in the 3rd and
4th bullets when N > 1?
Does the presence of t2, ..., tN get ignored, or does it make the
INVOKE ill formed?
Here is sample code which presents the problem in a concrete example:
#include <functional>
#include <cassert>
struct S {
char data;
};
typedef char S::*PMD;
int main()
{
S s;
PMD pmd = &S::data;
std::reference_wrapper<PMD> r(pmd);
r(s, 3.0) = 'a'; // well formed?
assert(s.data == 'a');
}
Without the "3.0" the example is well formed.
[Note: Daniel provided wording to make it explicit that the above example is ill-formed. — end note ]
[ Post-Rapperswil ]
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
[ Adopted at 2010-11 Batavia ]
Proposed resolution:
The wording refers to N3126.
Change 20.8.2 [func.require]/1 as indicated:
1 Define
INVOKE(f, t1, t2, ..., tN)as follows:
- ...
- ...
t1.*fwhenN == 1andfis a pointer to member data of a classTandt1is an object of typeTor a reference to an object of typeTor a reference to an object of a type derived fromT;(*t1).*fwhenN == 1andfis a pointer to member data of a classTandt1is not one of the types described in the previous item;- ...