Jens Maurer
N3277=11-0047
2011-03-25
N3277: Core issues 1194/1195/1199: References and constexpr
This paper presents the changes necessary to resolve core issues 1194
"Constexpr references", 1195 "References to non-literal types in
constexpr functions", and 1199 "Deleted constexpr functions".
Change in 3.9 basic.types paragraph 10:
A type is a literal type if it is:
- a scalar type; or
- a reference type; or
- ...
Change in 5.19 expr.const paragraph 1:
- an lvalue-to-rvalue conversion (4.1 conv.lval) unless it is applied to
- ...
- a glvalue of literal type that refers to a non-volatile temporary
object whose lifetime has not ended, initialized with a
constant expression;
[ Footnote: ... ]
- an id-expression that refers to a variable or data
member of reference type unless the reference has a preceding
initialization, initialized with a constant expression
[ Footnote: ... ];
Change in 7.1.5 dcl.constexpr paragraph 1:
The constexpr specifier shall be applied only to the
definition of an object a variable, the
declaration of a function or function template, or the declaration of
a static data member of a literal
type (3.9 basic.types). ...
Change in 7.1.5 dcl.constexpr paragraph 3:
- ...
- its return type shall be a literal type
or a reference to literal
type
- each of its parameter types shall be a literal type
or a
reference to literal type
- its function-body shall be
= delete
or a compound-statement of the form
{ return expression ; }
- ...
Change in 7.1.5 dcl.constexpr paragraph 4:
In a definition of a constexpr constructor, each of
the parameter types shall be a literal type. In addition, either its function-body shall be =
delete or it
The definition of a constexpr constructor
shall satisfy the following constraints:
each of its parameter types shall be a literal type or a reference
to literal type;
- ...
Change in 7.1.5 dcl.constexpr paragraph 8:
A constexpr specifier used in an object declaration
declares the object as const. Such an object shall be
initialized. If it is initialized by a constructor call, the
constructor shall be a constexpr constructor and every argument to the
constructor shall be a constant expression. Otherwise, or if a
constexpr specifier is used in a reference
declaration, every full-expression that appears in its
initializer shall be a constant expression.