[expr.mptr.oper]

# 7 Expressions [[expr]](./#expr)

## 7.6 Compound expressions [[expr.compound]](expr.compound#expr.mptr.oper)

### 7.6.4 Pointer-to-member operators [expr.mptr.oper]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L6956)

The pointer-to-member operators ->* and .* group
left-to-right[.](#1.sentence-1)

[pm-expression:](#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]")  
[*cast-expression*](expr.cast#nt:cast-expression "7.6.3 Explicit type conversion (cast notation) [expr.cast]")  
[*pm-expression*](#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]") .* [*cast-expression*](expr.cast#nt:cast-expression "7.6.3 Explicit type conversion (cast notation) [expr.cast]")  
[*pm-expression*](#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]") ->* [*cast-expression*](expr.cast#nt:cast-expression "7.6.3 Explicit type conversion (cast notation) [expr.cast]")

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L6973)

The binary operator .* binds its second operand, which shall be
a prvalue
of type âpointer to member of Tâ to its first operand, which shall be
a glvalue
of
class T or of a class of which T is an unambiguous and
accessible base class[.](#2.sentence-1)

The result is an object or a function of the type
specified by the second operand[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L6983)

The binary operator ->* binds its second operand, which shall be
a prvalue
of type âpointer to member of Tâ to its first operand, which shall be of
type âpointer to Uâ
where U is either T or
a class of which T is an unambiguous and accessible base class[.](#3.sentence-1)

The expression E1->*E2 is converted into the equivalent form(*(E1)).*E2[.](#3.sentence-2)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L6994)

Abbreviating [*pm-expression*](#nt:pm-expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]").*[*cast-expression*](expr.cast#nt:cast-expression "7.6.3 Explicit type conversion (cast notation) [expr.cast]") as E1.*E2, E1 is called the [*object expression*](#def:object_expression "7.6.4 Pointer-to-member operators [expr.mptr.oper]")[.](#4.sentence-1)

If the result of E1 is an object
whose type is not similar to the type of E1, or
whose most derived object does not
contain the member to whichE2 refers, the behavior is undefined[.](#4.sentence-2)

The expression E1 is sequenced before the expression E2[.](#4.sentence-3)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7004)

The restrictions on cv-qualification, and the manner in which
the cv-qualifiers of the operands are combined to produce the
cv-qualifiers of the result, are the same as the rules forE1.E2 given in [[expr.ref]](expr.ref "7.6.1.5 Class member access")[.](#5.sentence-1)

[*Note [1](#note-1)*:

It is not possible to use a pointer to member that refers to amutable member to modify a const class object[.](#5.sentence-2)

For
example,struct S { S() : i(0) { }mutable int i;};void f(){const S cs; int S::* pm = &S::i; // pm refers to mutable member S​::​i cs.*pm = 88; // error: cs is a const object}

â *end note*]

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L7027)

If the result of .* or ->* is a function, then that
result can be used only as the operand for the function call operator()[.](#6.sentence-1)

[*Example [1](#example-1)*:

(ptr_to_obj->*ptr_to_mfct)(10); calls the member function denoted by ptr_to_mfct for the object
pointed to by ptr_to_obj[.](#6.sentence-2)

â *end example*]

In a .* expression whose object expression is an rvalue, the program is
ill-formed if the second operand is a pointer to member function
whose [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]") is &,
unless its [*cv-qualifier-seq*](dcl.decl.general#nt:cv-qualifier-seq "9.3.1 General [dcl.decl.general]") is const[.](#6.sentence-3)

In a .* expression whose object expression is an lvalue, the program is ill-formed if the second
operand is
a pointer to member function
whose [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]") is &&[.](#6.sentence-4)

The result of a .* expression
whose second operand is a pointer to a data member is an lvalue if the first
operand is an lvalue and an xvalue otherwise[.](#6.sentence-5)

The result of a .* expression whose
second operand is a pointer to a member function is a prvalue[.](#6.sentence-6)

If the second operand is the [null member pointer value](conv.mem#def:value,null_member_pointer "7.3.13 Pointer-to-member conversions [conv.mem]"),
the behavior is undefined[.](#6.sentence-7)
