Skip to content

Commit fb8f9a7

Browse files
authored
Block intitalisation syntax, restore for loops
According to the maintainer’s comments.
1 parent 45c839d commit fb8f9a7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

docs/cpp/auto-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Conversion cases in which you might not want to use **`auto`**:
4040

4141
To use the **`auto`** keyword, use it instead of a type to declare a variable, and specify an initialization expression. In addition, you can modify the **`auto`** keyword by using specifiers and declarators such as **`const`**, **`volatile`**, pointer (**`*`**), reference (**`&`**), and rvalue reference (**`&&`**). The compiler evaluates the initialization expression and then uses that information to deduce the type of the variable.
4242

43-
The initialization expression can be passed using an assignment syntax (`auto int = 0;`) or a constructor syntax (`auto int (0);`). For more information, see [Initializers](../cpp/initializers.md) and the code examples later in this document.
43+
The initialization expression can be passed using an assignment syntax (`auto x = 0;`), a block syntax (`auto x { 0 };`} or a constructor syntax (`auto x (0);`). It is also used to declare the loop variable in a container-based iterator loop (`for (auto x : vector)`). For more information, see [Initializers](../cpp/initializers.md) and the code examples later in this document.
4444

4545
The **`auto`** keyword is a placeholder for a type, but it is not itself a type. Therefore, the **`auto`** keyword cannot be used in casts or operators such as [`sizeof`](../cpp/sizeof-operator.md) and (for C++/CLI) [`typeid`](../extensions/typeid-cpp-component-extensions.md).
4646

0 commit comments

Comments
 (0)