Affected subclauses: [class.ctor] and
[class.conv.fct]
Change: The class name can no longer be used parenthesized
immediately after an
explicit decl-specifier
in a constructor declaration
. Rationale: Necessary for new functionality
. Effect on original feature: Valid C++ 2017 code may fail to compile
in this International Standard
. For example:
struct S {
explicit (S)(const S&);
explicit (operator int)();
explicit(true) (S)(int);
};
Affected subclause: [class.copy.elision]
Change: A function returning an implicitly movable entity
may invoke a constructor taking an rvalue reference to a type
different from that of the returned expression
. Function and catch-clause parameters can be thrown using move constructors
. Rationale: Side effect of making it easier to write
more efficient code that takes advantage of moves
. Effect on original feature: Valid C++ 2017 code may fail to compile or have different semantics
in this International Standard
. For example:
struct base {
base();
base(base const &);
private:
base(base &&);
};
struct derived : base {};
base f(base b) {
throw b;
derived d;
return d;
}
struct S {
S(const char *s) : m(s) { }
S(const S&) = default;
S(S&& other) : m(other.m) { other.m = nullptr; }
const char * m;
};
S consume(S&& s) { return s; }
void g() {
S s("text");
consume(static_cast<S&&>(s));
char c = *s.m;
}