register

suggest change

A storage class specifier that hints to the compiler that a variable will be heavily used. The word “register” is related to the fact that a compiler might choose to store such a variable in a CPU register so that it can be accessed in fewer clock cycles. It was deprecated starting in C++11.

register int i = 0;
while (i < 100) {
    f(i);
    int g = i*i;
    i += h(i, g);
}

Both local variables and function parameters may be declared register. Unlike C, C++ does not place any restrictions on what can be done with a register variable. For example, it is valid to take the address of a register variable, but this may prevent the compiler from actually storing such a variable in a register.

The keyword register is unused and reserved. A program that uses the keyword register is ill-formed.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Storage class specifiers:
* register
* extern
* static
* auto

Table Of Contents
8 Arrays
11 Loops
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
124 Storage class specifiers
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype