Operator ->*: member access through an object pointer
The built-in ->* operator combines an object pointer with a pointer to a class member. It lets you read or modify a data member, or call a member function selected by that member pointer.
CKTIS / C++
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The built-in ->* operator combines an object pointer with a pointer to a class member. It lets you read or modify a data member, or call a member function selected by that member pointer.
Operator | either applies an adaptor closure to a range or composes two closures into a pipeline. Distinguish R | C, which invokes the adaptor, from C | D, which creates an operation for later use.
reinterpret_cast performs selected low-level conversions, primarily involving pointers and references. The cast itself does not authorize access through an incompatible type: aliasing, alignment, and object-lifetime rules still apply.
The built-in % operator computes the remainder of integer division. It is not a percentage operator or a guarantee of nonnegative modulo: a nonzero remainder has the sign of the dividend after type conversions. A zero divisor or an unrepresentable quotient causes undefined behavior.
The %= operator calculates a remainder and stores it in its left operand. The left side is evaluated only once. The built-in operator requires a modifiable integral object; a zero divisor causes undefined behavior.
The built-in >> operator shifts an integer's bits to the right. In C++23, its result corresponds to division by a power of two, rounded toward negative infinity. The number of positions shifted must be within the permitted range.
The >>= operator shifts the left operand's bits to the right and stores the result in the same object. The left operand is evaluated only once. Validity depends on the shift count and the type after integral promotion.
The :: operator qualifies a name by specifying the namespace, class, or enumeration in which it is looked up. A leading :: denotes the global namespace. It helps distinguish hidden names and define member functions outside the class definition.
The sizeof operator returns a type's size in bytes as a constant of type std::size_t. Its expression operand is not evaluated, and an array retains its full size rather than being converted to a pointer.
The sizeof... operator computes the number of elements in a parameter pack, not their size in bytes. Its result is an integral constant of type std::size_t; an empty pack yields 0.
The <=> operator, called spaceship, describes an ordering relationship between values. Standard result categories distinguish less, equivalent, greater, and sometimes unordered. In a class, a defaulted definition provides lexicographical comparison of subobjects.
static_cast<T>(expression) explicitly converts an expression to T under the language's conversion rules. The compiler checks whether the conversion is permitted, but does not guarantee value preservation or the validity of a class-hierarchy downcast.
The << operator writes values to an output stream. Learn the distinction between member overloads and non-member functions, and how to support a custom type while preserving chained insertion.
The symbol `-` means subtraction in `a - b` and arithmetic negation in `-x`. It can also move a pointer or calculate the distance between pointers. Correct results depend on type conversions, numeric ranges, and array boundaries.
The -= operator subtracts the right operand from the left operand's value and stores the result in the left object. For the built-in operator, the left operand is evaluated only once; type conversions and pointer arithmetic restrictions still apply.
The typeid operator exposes type information. For a polymorphic glvalue it identifies the dynamic type; otherwise it uses the static type.
Unary minus, written as -expression, computes the negated value. Learn how integral promotions affect the result, how unsigned negation works, and when signed overflow is a risk.
Unary + preserves its operand's value but can change its type through integral promotion. For an eligible noncapturing lambda, it can also force conversion to a function pointer.
The #include directive makes a header or source file's contents available during preprocessing. The <header> and "file" forms use different searches; the implementation defines the specific search rules.
Aggregate initialization initializes the elements of an aggregate, usually with a brace-enclosed list. Learn element ordering, omitted-member values, and the restrictions on designated initializers in C++23.
The declaration using AliasName = Type; gives a type another name without creating a distinct type. Learn its equivalence to typedef and how const applies to pointer aliases.
T name[N] declares a built-in array of N elements of type T. Its bound must be a positive compile-time constant; the elements occupy contiguous storage.
CTAD lets you omit class template arguments when initializing an object. The compiler selects a specialization using candidates derived from constructors and deduction guides. A guide selects the type but does not replace a constructor.
A const qualifier after a member function's parameter list restricts modification of the object through this. It permits calls through const objects, references, and pointers, but does not imply complete freedom from side effects.