Rationale: Necessary to enable single quotes as digit separators
. Effect on original feature: Valid C++ 2011 code may fail to compile or may change meaning in this
International Standard
. For example, the following code is valid both in C++ 2011 and in
this International Standard, but the macro invocation produces different outcomes
because the single quotes delimit a character literal in C++ 2011, whereas they are digit
separators in this International Standard:
#define M(x, ...) __VA_ARGS__
int x[2] = { M(1'2,3'4, 5) };
Rationale: Required for sized deallocation
.
Effect on original feature: Valid C++ 2011 code could declare a global placement allocation function and
deallocation function as follows:
void* operator new(std::size_t, std::size_t);
void operator delete(void*, std::size_t) noexcept;
In this International Standard, however, the declaration of
operator delete
might match a predefined usual (non-placement)
operator delete (
[basic.stc.dynamic])
. If so, the
program is ill-formed, as it was for class member allocation functions and
deallocation functions (
[expr.new])
. [expr.cond]
Change: A conditional expression with a throw expression as its second or third
operand keeps the type and value category of the other operand
. Rationale: Formerly mandated conversions (lvalue-to-rvalue (
[conv.lval]),
array-to-pointer (
[conv.array]), and function-to-pointer (
[conv.func])
standard conversions), especially the creation of the temporary due to
lvalue-to-rvalue conversion, were considered gratuitous and surprising
.
Effect on original feature: Valid C++ 2011 code that relies on the conversions may behave differently
in this International Standard:
struct S {
int x = 1;
void mf() { x = 2; }
};
int f(bool cond) {
S s;
(cond ? s : throw 0).mf();
return s.x;
}
In C++ 2011,
f(true) returns
1. In this International Standard,
it returns
2.
sizeof(true ? "" : throw 0)
In C++ 2011, the expression yields
sizeof(const char*). In this
International Standard, it yields
sizeof(const char[1]).[dcl.constexpr]
Change: constexpr non-static member functions are not implicitly
const member functions
. Rationale: Necessary to allow
constexpr member functions to mutate
the object
. Effect on original feature:
Valid C++ 2011 code may fail to compile in this International Standard
. For example, the following code is valid in C++ 2011
but invalid in this International Standard because it declares the same member
function twice with different return types:
struct S {
constexpr const int &f();
int &f();
};