<html>
<head>
<title>N3277: Core issues 1194/1195/1199: References and constexpr</title>

<style type="text/css">
  ins { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  del { text-decoration:line-through; background-color:#FFA0A0 }
</style>
</head>

<body>
Jens Maurer<br/>
N3277=11-0047<br/>
2011-03-25

<h1>N3277: Core issues 1194/1195/1199: References and constexpr</h1>

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".
<p>

<hr/>

Change in 3.9 basic.types paragraph 10:

<blockquote>
A type is a literal type if it is:
<ul>
<li>a scalar type; or</li>
<li><ins>a reference type; or</ins></li>
<li> ...</li>
</ul>
</blockquote>

Change in 5.19 expr.const paragraph 1:

<blockquote>
<ul>
<li>an lvalue-to-rvalue conversion (4.1 conv.lval) unless it is applied to
<ul>
<li>...</li>
<li>a glvalue of literal type that refers to a non-volatile temporary
object <ins>whose lifetime has not ended,</ins> initialized with a
constant expression; <del>[ Footnote: ... ]</del>
</ul>
<li>an <em>id-expression</em> that refers to a variable or data
member of reference type <ins>unless the reference has a preceding
initialization, initialized with a constant expression</ins>
<del>[ Footnote: ... ]</del>;</li>
</ul>
</blockquote>

Change in 7.1.5 dcl.constexpr paragraph 1:

<blockquote>
The <code>constexpr</code> specifier shall be applied only to the
definition of <del>an object</del> <ins>a variable</ins>, the
declaration of a function or function template, or the declaration of
a static data member of a literal
type (3.9 basic.types). ...
</blockquote>

Change in 7.1.5 dcl.constexpr paragraph 3:

<blockquote>
<ul>
<li>...</li>
<li>its return type shall be a literal type <del>or a reference to literal
type</del></li>
<li>each of its parameter types shall be a literal type <del>or a
reference to literal type</del></li>
<li>its <em>function-body</em> shall be <ins><code>= delete</code>
or</ins> a <em>compound-statement</em> of the form
<pre>
    { return <em>expression</em> ; }
</pre></li>
<li>...</li>
</ul>
</blockquote>

Change in 7.1.5 dcl.constexpr paragraph 4:

<blockquote>
<ins>In a definition of a <code>constexpr</code> constructor, each of
the parameter types shall be a literal type.  In addition, either its <em>function-body</em> shall be <code>=
delete</code> or it</ins>
<del>
The definition of a <code>constexpr</code> constructor</del>
shall satisfy the following constraints:

<ul>
<li><del>each of its parameter types shall be a literal type or a reference
to literal type;</del></li>
<li>...</li>
</ul>
</blockquote>


Change in 7.1.5 dcl.constexpr paragraph 8:

<blockquote>
A <code>constexpr</code> specifier used in an object declaration
declares the object as <code>const</code>. 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, <ins>or if a
<code>constexpr</code> specifier is used in a reference
declaration,</ins> every full-expression that appears in its
initializer shall be a constant expression.
</blockquote>

</body>
</html>
