tmp/tmpgwvff4hq/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### [[class]]: classes <a id="diff.cpp17.class">[[diff.cpp17.class]]</a>
|
| 2 |
+
|
| 3 |
+
**Change:** The class name can no longer be used parenthesized
|
| 4 |
+
immediately after an `explicit` *decl-specifier* in a constructor
|
| 5 |
+
declaration. The *conversion-function-id* can no longer be used
|
| 6 |
+
parenthesized immediately after an `explicit` *decl-specifier* in a
|
| 7 |
+
conversion function declaration. **Rationale:** Necessary for new
|
| 8 |
+
functionality. **Effect on original feature:** Valid C++17 code may fail
|
| 9 |
+
to compile in this International Standard. For example:
|
| 10 |
+
|
| 11 |
+
``` cpp
|
| 12 |
+
struct S {
|
| 13 |
+
explicit (S)(const S&); // ill-formed; previously well-formed
|
| 14 |
+
explicit (operator int)(); // ill-formed; previously well-formed
|
| 15 |
+
explicit(true) (S)(int); // OK
|
| 16 |
+
};
|
| 17 |
+
```
|
| 18 |
+
|
| 19 |
+
**Change:** A *simple-template-id* is no longer valid as the
|
| 20 |
+
*declarator-id* of a constructor or destructor. **Rationale:** Remove
|
| 21 |
+
potentially error-prone option for redundancy. **Effect on original
|
| 22 |
+
feature:** Valid C++17 code may fail to compile in this International
|
| 23 |
+
Standard. For example:
|
| 24 |
+
|
| 25 |
+
``` cpp
|
| 26 |
+
template<class T>
|
| 27 |
+
struct A {
|
| 28 |
+
A<T>(); // error: simple-template-id not allowed for constructor
|
| 29 |
+
A(int); // OK, injected-class-name used
|
| 30 |
+
~A<T>(); // error: simple-template-id not allowed for destructor
|
| 31 |
+
};
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
**Change:** A function returning an implicitly movable entity may invoke
|
| 35 |
+
a constructor taking an rvalue reference to a type different from that
|
| 36 |
+
of the returned expression. Function and catch-clause parameters can be
|
| 37 |
+
thrown using move constructors. **Rationale:** Side effect of making it
|
| 38 |
+
easier to write more efficient code that takes advantage of moves.
|
| 39 |
+
**Effect on original feature:** Valid C++17 code may fail to compile or
|
| 40 |
+
have different semantics in this International Standard. For example:
|
| 41 |
+
|
| 42 |
+
``` cpp
|
| 43 |
+
struct base {
|
| 44 |
+
base();
|
| 45 |
+
base(base const &);
|
| 46 |
+
private:
|
| 47 |
+
base(base &&);
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
struct derived : base {};
|
| 51 |
+
|
| 52 |
+
base f(base b) {
|
| 53 |
+
throw b; // error: base(base &&) is private
|
| 54 |
+
derived d;
|
| 55 |
+
return d; // error: base(base &&) is private
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
struct S {
|
| 59 |
+
S(const char *s) : m(s) { }
|
| 60 |
+
S(const S&) = default;
|
| 61 |
+
S(S&& other) : m(other.m) { other.m = nullptr; }
|
| 62 |
+
const char * m;
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
S consume(S&& s) { return s; }
|
| 66 |
+
|
| 67 |
+
void g() {
|
| 68 |
+
S s("text");
|
| 69 |
+
consume(static_cast<S&&>(s));
|
| 70 |
+
char c = *s.m; // undefined behavior; previously ok
|
| 71 |
+
}
|
| 72 |
+
```
|
| 73 |
+
|