Created on 2025-05-11.00:00:00 last changed 1 month ago
Suggested resolution:
Change in 7.6.2.2 [expr.unary.op] bullet 3.1 as follows:
The operand of the unary & operator shall be an lvalue of some type T.
- If the operand is a qualified-id naming a non-static
or variantclass member mof some class C, other than an explicit object member function, then let C be the class, that is not an anonymous union, of which m is a direct member.theThe result has type “pointer to member of class C of type T” and designates C::m. [Note: A qualified-id that names a member of a namespace-scope anonymous union is considered to be a class member access expression (7.5.5.1 [expr.prim.id.general]) and thus cannot be used to form a pointer to member.-- end note]- ...
(From submission #705.)
Consider:
struct A { union { int x; }; int y; }; struct B : A {}; template <typename> struct Q; template <> struct Q<A> {}; template <typename T> Q<T> f(int T::*); Q<A> g() { return f(&B::x); } // OK Q<A> h() { return f(&B::y); } // OK
For both cases, the pointer to member is of type "pointer to member of class A", but the wording is not clear.
History | |||
---|---|---|---|
Date | User | Action | Args |
2025-05-11 06:06:18 | admin | set | messages: + msg8024 |
2025-05-11 00:00:00 | admin | create |