|
1466 | 1466 | \begin{example}
|
1467 | 1467 | \begin{codeblock}
|
1468 | 1468 | template <class T> struct A {
|
1469 |
| - explicit A(const T&, ...) noexcept; // \#1 |
1470 |
| - A(T&&, ...); // \#2 |
| 1469 | + explicit A(const T&, ...) noexcept; // \#1 |
| 1470 | + A(T&&, ...); // \#2 |
1471 | 1471 | };
|
1472 | 1472 |
|
1473 | 1473 | int i;
|
|
1713 | 1713 | };
|
1714 | 1714 |
|
1715 | 1715 | int main() {
|
1716 |
| - B b; // OK, \tcode{B::B()} |
| 1716 | + B b; // OK, \tcode{B::B()} |
1717 | 1717 | }
|
1718 | 1718 | \end{codeblock}
|
1719 | 1719 | \end{example}
|
|
2232 | 2232 | \begin{codeblock}
|
2233 | 2233 | struct A { int x, y; };
|
2234 | 2234 | struct B { int y, x; };
|
2235 |
| -void f(A a, int); // \#1 |
2236 |
| -void f(B b, ...); // \#2 |
2237 |
| -void g(A a); // \#3 |
2238 |
| -void g(B b); // \#4 |
| 2235 | +void f(A a, int); // \#1 |
| 2236 | +void f(B b, ...); // \#2 |
| 2237 | +void g(A a); // \#3 |
| 2238 | +void g(B b); // \#4 |
2239 | 2239 | void h() {
|
2240 |
| - f({.x = 1, .y = 2}, 0); // OK; calls \#1 |
2241 |
| - f({.y = 2, .x = 1}, 0); // error: selects \#1, initialization of \tcode{a} fails |
2242 |
| - // due to non-matching member order\iref{dcl.init.list} |
2243 |
| - g({.x = 1, .y = 2}); // error: ambiguous between \#3 and \#4 |
| 2240 | + f({.x = 1, .y = 2}, 0); // OK; calls \#1 |
| 2241 | + f({.y = 2, .x = 1}, 0); // error: selects \#1, initialization of \tcode{a} fails |
| 2242 | + // due to non-matching member order\iref{dcl.init.list} |
| 2243 | + g({.x = 1, .y = 2}); // error: ambiguous between \#3 and \#4 |
2244 | 2244 | }
|
2245 | 2245 | \end{codeblock}
|
2246 | 2246 | \end{example}
|
|
2271 | 2271 | the context of a call to an initializer-list constructor. \begin{example}
|
2272 | 2272 | \begin{codeblock}
|
2273 | 2273 | void f(std::initializer_list<int>);
|
2274 |
| -f( {} ); // OK: \tcode{f(initializer_list<int>)} identity conversion |
2275 |
| -f( {1,2,3} ); // OK: \tcode{f(initializer_list<int>)} identity conversion |
2276 |
| -f( {'a','b'} ); // OK: \tcode{f(initializer_list<int>)} integral promotion |
2277 |
| -f( {1.0} ); // error: narrowing |
| 2274 | +f( {} ); // OK: \tcode{f(initializer_list<int>)} identity conversion |
| 2275 | +f( {1,2,3} ); // OK: \tcode{f(initializer_list<int>)} identity conversion |
| 2276 | +f( {'a','b'} ); // OK: \tcode{f(initializer_list<int>)} integral promotion |
| 2277 | +f( {1.0} ); // error: narrowing |
2278 | 2278 |
|
2279 | 2279 | struct A {
|
2280 | 2280 | A(std::initializer_list<double>); // \#1
|
2281 | 2281 | A(std::initializer_list<complex<double>>); // \#2
|
2282 | 2282 | A(std::initializer_list<std::string>); // \#3
|
2283 | 2283 | };
|
2284 |
| -A a{ 1.0,2.0 }; // OK, uses \#1 |
| 2284 | +A a{ 1.0,2.0 }; // OK, uses \#1 |
2285 | 2285 |
|
2286 | 2286 | void g(A);
|
2287 |
| -g({ "foo", "bar" }); // OK, uses \#3 |
| 2287 | +g({ "foo", "bar" }); // OK, uses \#3 |
2288 | 2288 |
|
2289 | 2289 | typedef int IA[3];
|
2290 | 2290 | void h(const IA&);
|
2291 |
| -h({ 1, 2, 3 }); // OK: identity conversion |
| 2291 | +h({ 1, 2, 3 }); // OK: identity conversion |
2292 | 2292 | \end{codeblock}
|
2293 | 2293 | \end{example}
|
2294 | 2294 |
|
|
3304 | 3304 | Z operator[](std::initializer_list<int>);
|
3305 | 3305 | };
|
3306 | 3306 | X x;
|
3307 |
| -x[{1,2,3}] = 7; // OK: meaning \tcode{x.operator[](\{1,2,3\})} |
| 3307 | +x[{1,2,3}] = 7; // OK: meaning \tcode{x.operator[](\{1,2,3\})} |
3308 | 3308 | int a[10];
|
3309 |
| -a[{1,2,3}] = 7; // error: built-in subscript operator |
| 3309 | +a[{1,2,3}] = 7; // error: built-in subscript operator |
3310 | 3310 | \end{codeblock}
|
3311 | 3311 | \end{example}
|
3312 | 3312 |
|
|
0 commit comments