|
174 | 174 | a \defn{structured binding declaration}\iref{dcl.struct.bind}.
|
175 | 175 | If the \grammarterm{decl-specifier-seq} contains
|
176 | 176 | any \grammarterm{decl-specifier} other than
|
177 |
| -\tcode{static}, \tcode{thread_local}, \tcode{auto}\iref{dcl.spec.auto}, or |
| 177 | +\tcode{static}, \tcode{thread_local}, \keyword{auto}\iref{dcl.spec.auto}, or |
178 | 178 | \grammarterm{cv-qualifier}{s},
|
179 | 179 | the program is ill-formed.
|
180 | 180 | The \grammarterm{initializer} shall be
|
|
1666 | 1666 |
|
1667 | 1667 | \pnum
|
1668 | 1668 | A \grammarterm{placeholder-type-specifier} of the form
|
1669 |
| -\opt{\grammarterm{type-constraint}} \tcode{auto} |
| 1669 | +\opt{\grammarterm{type-constraint}} \keyword{auto} |
1670 | 1670 | can be used as a \grammarterm{decl-specifier} of
|
1671 | 1671 | the \grammarterm{decl-specifier-seq} of
|
1672 | 1672 | a \grammarterm{parameter-declaration} of
|
1673 | 1673 | a function declaration or \grammarterm{lambda-expression} and,
|
1674 |
| -if it is not the \tcode{auto} \grammarterm{type-specifier} |
| 1674 | +if it is not the \keyword{auto} \grammarterm{type-specifier} |
1675 | 1675 | introducing a \grammarterm{trailing-return-type} (see below),
|
1676 | 1676 | is a \defn{generic parameter type placeholder}
|
1677 | 1677 | of the function declaration or \grammarterm{lambda-expression}.
|
|
1716 | 1716 | auto x = 5; // OK: \tcode{x} has type \tcode{int}
|
1717 | 1717 | const auto *v = &x, u = 6; // OK: \tcode{v} has type \tcode{const int*}, \tcode{u} has type \tcode{const int}
|
1718 | 1718 | static auto y = 0.0; // OK: \tcode{y} has type \tcode{double}
|
1719 |
| -auto int r; // error: \tcode{auto} is not a \grammarterm{storage-class-specifier} |
| 1719 | +auto int r; // error: \keyword{auto} is not a \grammarterm{storage-class-specifier} |
1720 | 1720 | auto f() -> int; // OK: \tcode{f} returns \tcode{int}
|
1721 | 1721 | auto g() { return 0.0; } // OK: \tcode{g} returns \tcode{double}
|
1722 | 1722 | auto h(); // OK: \tcode{h}'s return type will be deduced when it is defined
|
1723 | 1723 | \end{codeblock}
|
1724 | 1724 | \end{example}
|
1725 |
| -The \tcode{auto} \grammarterm{type-specifier} |
| 1725 | +The \keyword{auto} \grammarterm{type-specifier} |
1726 | 1726 | can also be used to introduce
|
1727 | 1727 | a structured binding declaration\iref{dcl.struct.bind}.
|
1728 | 1728 |
|
|
1750 | 1750 |
|
1751 | 1751 | \begin{example}
|
1752 | 1752 | \begin{codeblock}
|
1753 |
| -auto x = 5, *y = &x; // OK: \tcode{auto} is \tcode{int} |
1754 |
| -auto a = 5, b = { 1, 2 }; // error: different types for \tcode{auto} |
| 1753 | +auto x = 5, *y = &x; // OK: \keyword{auto} is \tcode{int} |
| 1754 | +auto a = 5, b = { 1, 2 }; // error: different types for \keyword{auto} |
1755 | 1755 | \end{codeblock}
|
1756 | 1756 | \end{example}
|
1757 | 1757 |
|
|
1836 | 1836 | auto f();
|
1837 | 1837 | auto f() { return 42; } // return type is \tcode{int}
|
1838 | 1838 | auto f(); // OK
|
1839 |
| -int f(); // error: \tcode{auto} and \tcode{int} don't match |
1840 |
| -decltype(auto) f(); // error: \tcode{auto} and \tcode{decltype(auto)} don't match |
| 1839 | +int f(); // error: \keyword{auto} and \tcode{int} don't match |
| 1840 | +decltype(auto) f(); // error: \keyword{auto} and \tcode{decltype(auto)} don't match |
1841 | 1841 |
|
1842 | 1842 | template <typename T> auto g(T t) { return t; } // \#1
|
1843 | 1843 | template auto g(int); // OK, return type is \tcode{int}
|
|
1928 | 1928 | or with an operand of type \keyword{void},
|
1929 | 1929 | \tcode{T} shall be either
|
1930 | 1930 | \opt{\grammarterm{type-constraint}} \tcode{decltype(auto)} or
|
1931 |
| -\cv{}~\opt{\grammarterm{type-constraint}} \tcode{auto}. |
| 1931 | +\cv{}~\opt{\grammarterm{type-constraint}} \keyword{auto}. |
1932 | 1932 |
|
1933 | 1933 | \pnum
|
1934 | 1934 | If the deduction is for a \tcode{return} statement
|
|
1937 | 1937 |
|
1938 | 1938 | \pnum
|
1939 | 1939 | If the \grammarterm{placeholder-type-specifier} is of the form
|
1940 |
| -\opt{\grammarterm{type-constraint}} \tcode{auto}, |
| 1940 | +\opt{\grammarterm{type-constraint}} \keyword{auto}, |
1941 | 1941 | the deduced type
|
1942 | 1942 | $\mathtt{T}'$ replacing \tcode{T}
|
1943 | 1943 | is determined using the rules for template argument deduction.
|
1944 | 1944 | Obtain \tcode{P} from
|
1945 | 1945 | \tcode{T} by replacing the occurrences of
|
1946 |
| -\opt{\grammarterm{type-constraint}} \tcode{auto} either with |
| 1946 | +\opt{\grammarterm{type-constraint}} \keyword{auto} either with |
1947 | 1947 | a new invented type template parameter \tcode{U} or,
|
1948 | 1948 | if the initialization is copy-list-initialization, with
|
1949 | 1949 | \tcode{std::initializer_list<U>}. Deduce a value for \tcode{U} using the rules
|
|
2149 | 2149 | S S;
|
2150 | 2150 | S T; // error
|
2151 | 2151 | \end{codeblock}
|
2152 |
| -Another exception is when \tcode{T} is \tcode{auto}\iref{dcl.spec.auto}, |
| 2152 | +Another exception is when \tcode{T} is \keyword{auto}\iref{dcl.spec.auto}, |
2153 | 2153 | for example:
|
2154 | 2154 | \begin{codeblock}
|
2155 | 2155 | auto i = 1, j = 2.0; // error: deduced types for \tcode{i} and \tcode{j} do not match
|
|
3365 | 3365 | \tcode{D1}
|
3366 | 3366 | is
|
3367 | 3367 | ``\placeholder{derived-declarator-type-list} \tcode{T}'',
|
3368 |
| -\tcode{T} shall be the single \grammarterm{type-specifier} \tcode{auto}. |
| 3368 | +\tcode{T} shall be the single \grammarterm{type-specifier} \keyword{auto}. |
3369 | 3369 | The type of the
|
3370 | 3370 | \grammarterm{declarator-id}
|
3371 | 3371 | in
|
|
3727 | 3727 | one invented type \grammarterm{template-parameter}
|
3728 | 3728 | for each generic parameter type placeholder
|
3729 | 3729 | of the function declaration, in order of appearance.
|
3730 |
| -For a \grammarterm{placeholder-type-specifier} of the form \tcode{auto}, |
| 3730 | +For a \grammarterm{placeholder-type-specifier} of the form \keyword{auto}, |
3731 | 3731 | the invented parameter is
|
3732 | 3732 | an unconstrained \grammarterm{type-parameter}.
|
3733 | 3733 | For a \grammarterm{placeholder-type-specifier} of the form
|
3734 |
| -\grammarterm{type-constraint} \tcode{auto}, |
| 3734 | +\grammarterm{type-constraint} \keyword{auto}, |
3735 | 3735 | the invented parameter is a \grammarterm{type-parameter} with
|
3736 | 3736 | that \grammarterm{type-constraint}.
|
3737 | 3737 | The invented type \grammarterm{template-parameter} is
|
|
3829 | 3829 | of a \grammarterm{parameter-declaration-clause} without a preceding
|
3830 | 3830 | comma. In this case, the ellipsis is parsed as part of the
|
3831 | 3831 | \grammarterm{abstract-declarator} if the type of the parameter either names
|
3832 |
| -a template parameter pack that has not been expanded or contains \tcode{auto}; |
| 3832 | +a template parameter pack that has not been expanded or contains \keyword{auto}; |
3833 | 3833 | otherwise, it is
|
3834 | 3834 | parsed as part of the \grammarterm{parameter-declaration-clause}.
|
3835 | 3835 | \begin{footnote}
|
|
0 commit comments