Title
INVOKE on member data pointer with too many arguments
Status
c++11
Section
[func.require]
Submitter
Howard Hinnant

Created on 2010-10-10.00:00:00 last changed 161 months ago

Messages

Date: 2010-11-23.13:22:14

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.*f when N == 1 and f is a pointer to member data of a class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T;
  • (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1 is not one of the types described in the previous item;
  • ...
Date: 2010-11-23.13:22:14

[ Adopted at 2010-11 Batavia ]

Date: 2010-10-21.19:47:27

[ Post-Rapperswil ]

Moved to Tentatively Ready after 5 positive votes on c++std-lib.

Date: 2010-10-10.00:00:00

20.8.2 [func.require] p1 says:

1 Define INVOKE(f, t1, t2, ..., tN) as follows:

  • (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T;
  • ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a class T and t1 is not one of the types described in the previous item;
  • t1.*f when f is a pointer to member data of a class T and t1 is an object of type T or a reference to an object of type T or a reference to an object of a type derived from T;
  • (*t1).*f when f is a pointer to member data of a class T and t1 is 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 ]

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-11-23 13:22:14adminsetmessages: + msg5410
2010-11-14 13:10:57adminsetstatus: voting -> wp
2010-11-08 14:14:39adminsetstatus: ready -> voting
2010-10-21 19:47:27adminsetmessages: + msg4887
2010-10-21 19:47:27adminsetmessages: + msg4886
2010-10-10 00:00:00admincreate