Member access operators

Accesses a member of its operand.

# Declarations

T& operator[](T*, std::ptrdiff_t);
T& operator[](std::ptrdiff_t, T*);

# Notes

Feature-test macro Value Std Feature __cpp_multidimensional_subscript 202110L (C++23) Multidimensional subscript operator

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
CWG 1213C++11subscripting an array rvalue resulted in lvaluereclassified as xvalue
CWG 1458C++98applying & to an lvalue of incomplete class type whichdeclares operator& resulted in undefined behaviorit is unspecifiedwhich & is used
CWG 1642C++98the rhs  in built-in pointer-to-member access operators could be an lvaluecan only be an rvalue
CWG 1800C++98when applying & to a non-static data member of amember anonymous union, it was unclear whetherthe anonymous union take a part in the result typethe anonymous unionis not included inthe result type
CWG 2614C++98the result of E1.E2 was unclear if E2 is a reference member or enumeratormade clear
CWG 2725C++98if E2 is a static member function, E1.E2 is well-formedeven if it is not the left hand opreand of operator()E1.E2 is ill-formedin this case
CWG 2748C++98the behavior of E1->E2 was unclear if E1 is anull pointer and E2 refers to a static memberthe behavior isundefined in this case
CWG 2813C++98E1 was not a discarded-value expression ifE1.E2 names a static member or enumerationit is
CWG 2823C++98the behavior of *expr was unclear if exprdoes not point to an object or functionmade clear

# See also