<html>
<head>
<title>Defaulted and Deleted Functions</title>
</head>

<body>
<h1>Defaulted and Deleted Functions</h1>

<p>ISO/IEC JTC1 SC22 WG21 N2326 = 07-0186 - 2007-06-22

<p>Lawrence Crowl, Lawrence@Crowl.org, crowl@google.com

<p>This document is a revision of
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2210.html">
N2210</a> = 07-0070 - 2007-03-11.

<h2>Overview</h2>

<p>We propose a syntax and semantics
for explicitly using the default definition of a function.
We also propose a syntax and semantics
for deleting the definition of an otherwise visible function.

<ul>
<li><a href="#problem">Problem Description</a></li>
<li><a href="#prior">Prior Approaches</a><ul>
    <li><a href="#classusing">Class Scope Using Declarations
                              and Private Members</a></li>
    <li><a href="#explicit">Explicit Classes and Default Definitions</a></li>
    <li><a href="#list">List of Class Defaults</a></li>
    <li><a href="#prohibited">Prohibited Access Specifier</a></li>
    </ul></li>
<li><a href="#solution">Proposed Solution</a><ul>
    <li><a href="#default">Default Function Definition</a><ul>
        <li><a href="#trivial">Trivial Definitions</a></li>
        <li><a href="#exception">Exception Specification</a></li>
        <li><a href="#nonimplicit">Non-Implicit Defaults</a></li>
        </ul></li>
    <li><a href="#delete">Delete Function Definition</a><ul>
        <li><a href="#features">Disabling Language Features</a></li>
        <li><a href="#conversions">Disabling Undesired Conversions</a></li>
        </ul></li>
    <li><a href="#comparison">Comparison to Prior Approaches</a></li>
    </ul></li>
<li><a href="#usecase">Use Case - Atomic Types</a></li>
<li><a href="#changes">Changes to the Standard</a><ul>
    <li><a href="#definitions">8.4 Function definitions [dcl.fct.def]</a></li>
    <li><a href="#override">10.3 Virtual functions [class.virtual]</a></li>
    <li><a href="#constructors">12.1 Constructors [class.ctor]</a></li>
    <li><a href="#destructors">12.4 Destructors [class.dtor]</a></li>
    <li><a href="#copying">12.8 Copying class objects [class.copy]</a></li>
    <li><a href="#address">13.4 Address of overloaded function
                           [over.over]</a></li>
    </ul></li>
</ul>



<h2><a name="problem">Problem Description</a></h2>

<p>By default, C++ provides four default special member functions:
<ul>
<li>destructor</li>
<li>default constructor</li>
<li>copy constructor</li>
<li>copy assignment <code>operator =</code></li>
</ul>
Users may override these defaults.

<p>Also by default, C++ applies several global operators to classes:
<ul>
<li>sequence <code>operator ,</code></li>
<li>address-of <code>operator &amp;</code></li>
<li>indirection <code>operator *</code></li>
<li>member access <code>operator -&gt;</code></li>
<li>member indirection <code>operator -&gt;*</code></li>
<li>free-store allocation <code>operator new</code></li>
<li>free-store deallocation <code>operator delete</code></li>
</ul>
Users may provide class-specific operators.

<p>The management of defaults has several problems:
<ul>
<li>Constructor definitions are coupled;
declaring any constructor suppresses the default constructor.</li>
<li>The destructor default is inappropriate to polymorphic classes,
requiring an explicit definition.</li>
<li>Once a default is suppressed, there is no means to resurrect it.</li> 
<li>Default implementations are often more efficient
than manually specified implementations.</li>
<li>Non-default implementations are non-trivial,
which affects type semantics,
e.g. makes a type non-POD.</li>
<li>There is no means to prohibit a special member function or global operator
without declaring a (non-trivial) substitute.</li>
</ul>

<p>The most common encounter with these problems
is when disabling copying of a class.
The accepted technique is to
declare a private copy constructor and a private copy assignment operator,
and then fail to define either.
Unfortunately, the type becomes non-POD
and its default constructor must be explicitly written.
Further,
while diagnostics for non-friend uses are relatively straightforward,
the diagnostics for friend uses are deferred to link time
and a cryptic a <q>missing symbol</q> message.

<p>The specific problem of concisely ensuring that a class is non-copyable
has received attention from <a href="http://www.boost.org/">Boost</a>.
See the
<a href="http://www.boost.org/libs/utility/utility.htm#Class_noncopyable">
documentation</a> and
<a href="http://www.boost.org/boost/noncopyable.hpp">header</a>
for the boost::noncopyable mixin.
This mixin works,
though not with entirely satisfactory results.
First, the mechanism uses a base class,
which under the current language makes the class non-POD.
Second, the error messages can be somewhat misleading.

<p>Any successful solution to these problems
must be relatively easy to learn and implement.



<h2><a name="prior">Prior Approaches</a></h2>

<p>The problems of defaults
has been addressed via four primary approaches,
as described below.
These approaches have significant overlap,
but none provide all of the capabilities of any of the others.


<h3><a name="classusing">Class Scope Using Declarations and Private Members</a></h3>

<p> In
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1602.pdf">
<cite>N1602 Class Scope Using Declarations &amp; private Members</cite></a>,
Francis Glassborow notes that some programmers make problematic
overloads private members to prevent their use.
This approach makes using valid overloads in derived classes an error,
thus inhibiting the technique.
He proposes defering the error diagnostic to the point where a private
overload is selected in a call.

<h3><a name="explicit">Explicit Classes and Default Definitions</a></h3>

<p>In
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
<cite>N1717 explicit class and default definitions</cite></a>,
Francis Glassborow and Lois Goldthwaite
define syntax to indicate that
a class has none of the four default special member functions
and then to explicitly resurrect the desired defaults.
The paper proposed no change to the default application of global operators.

<p>The explicit class approach
has a significant syntactic burden
for removing a single special member function --
remove them all and rewrite the declarations for the others.
This approach encourages a view that explicit classes are inherently different,
rather than a restriction of regular classes.

<p>The paper states that
<blockquote>
Special member functions
which have been explicitly declared and default-defined
are never trivial.
Therefore an explicit class can never be a POD,
even if its special member functions are default-defined.
(The justification for this restriction
is that the semantics of a class should not change
if its inline default-defined functions are moved out of line.)
</blockquote>
However, this is too much of a restriction.
An inline default-defined function should be trivial
if and only if the implicit definition would be trivial.
Of course, non-inline definitions should be non-trivial.
In essence, we agree with the justification,
but not the restriction.
Fortunately, subsequent work on the definition of PODs
by Beman Dawes in
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2102.html">
<cite>N2172 POD's Revisited;
Resolving Core Issue 568 (Revision 2)</cite></a>)
provides tools to revisit this issue.

<p>The suggested syntax for explicit defaults
permits simultaneous specification of a member initializer list,
which is clearly not right.
Rather than add additional restrictive text,
a restrictive syntax is preferable.

<p>The paper left incomplete the specification that
an explicit class without a copy constructor
is deemed to have an inaccessible copy constructor.
This specification was intended to avoid reverse slicing,
where only a sub-object is initialized.
The situation is similar for copy assignment operators.


<h3><a name="list">List of Class Defaults</a></h3>

<p>In
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1890.pdf">
<cite>N1890 Initialization and Initializers</cite></a> section 7,
as elaborated in the draft
<a href="http://wiki.dinkumware.com/twiki/pub/Wg21portland/EvolutionWorkingGroup/controlofdefaults.pdf">
<cite>Control of class defaults</cite></a>,
Bjarne Stroustrup
describes a syntax for controlling defaults,
with more goals than
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>.
These goals include not only controlling member defaults,
but also controlling the application of global operators,
other possible default implementations,
and control of inheritance.

<p>The paper's proposed syntax is very terse,
and requires a mental mapping from the short codes
of the default control list to the actual functions.
For the most part, this mapping is straightforward,
but still must be memorized.
Further, its different syntactic style will slow adoption
by users and compiler vendors.

<p>In contrast to
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>,
the paper provides no mechanism
to define a non-inline member using the default definition.

<p>The paper also includes mechanisms for controlling
<q>class defaults</q>,
which essentially involve inheritance.
<ul>
<li>Member functions are non-virtual by default.</li>
<li>Member functions are non-pure by default.</li>
<li>Classes are inheritable by default.</li>
<li>Virtual member functions are overridable by default.</li>
</ul>
In the current language:
member functions are easily made virtual, but only individually;
it is possible to prevent inheritance of a class,
but not also allocate variables of that class;
and there is no mechanism to prevent virtual overriding.
This paper addresses these inheritance issues as well.


<h3><a name="prohibited">Prohibited Access Specifier</a></h3>

<p>In
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2123.html">
<cite>N2123 Adding the prohibited access specifier to C++09</cite></a>
Alisdair Meredith
describes a <code>prohibited</code> access specifier
that disables undesired operations within classes.
This notion was first introduced by
Daveed Vandevoorde in
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1964.pdf">
<cite>N1964 Modules in C++ (revision 3)</cite></a>.

<p>The proposal also enables defining prohibited conversions
via declaration of a prohibited overload.
This aspect of the proposal is probably the most significant,
as it extends into user-defined operations
and addresses a major weakness in C++, agressive conversion.

<p> The technique works because the prohibited functions are still visible.
Syntactically, the specifier also applies to other data members,
for which it does not make sense and requires additional rules.
A more precise mechanism is desirable.

<p>Furthermore, the access specifier does not work for free functions.
This missing feature seems like such an obvious next step
that its absence will be felt.

<p>The <code>prohibited</code> keyword is new,
which will break some programs.
A Google code search yields about 500 hits.
Sensibly reusing an existing keyword will not affect existing programs.

<p>Unlike
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>,
the paper does not propose a means to specify
non-inline default implementations.
Unlike
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1890.pdf">
N1890</a>,
the paper does not propose a means to specify
default implementations for functions that have no implicit default.



<h2><a name="solution">Proposed Solution</a></h2>

<p>We propose to define two new mechanisms
to explicitly use the default definition of a function
and to delete a function definition.
This solution
<ul>
<li>provides for full control of special member function defaults,</li>
<li>provides maximally trivial special member function definitions
(thus obtaining maximum benefit from
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2102.html">
N2172</a>),</li>
<li>does not require modification of class syntax,</li>
<li>does not introduce new keywords,</li>
<li>does not apply syntactically to data, and</li>
<li>applies to free functions as well as member functions.</li>
</ul>

<p>Syntactically, the proposal uses
<q><code>=default;</code></q> and <q><code>=delete;</code></q>
in alternate rules for <var>function-definition</var>.
We considered the forms
<q><code>default;</code></q>, as suggested by
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>, and
<q><code>{default}</code></q>, as adopted by
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>,
but chose not to use them.
The reasons are that the former introduces
more choice points into the parse of declarations,
while the second introduces either
more choice points in the parse of function blocks
or substantial lookahead to determine that the syntax
<q><code>{default}</code></q> is not a function block.


<h3><a name="default">Default Function Definition</a></h3>

<p>The definition form <q><code>=default;</code></q>
indicates that the function's default definition should be used.
As expected, this works when the definition is inside the class body,
but it also works when the definition is outside the class body,
but as with the current language,
you must declare the function within the class body.

<pre><code>
struct type
{
    type() = default; // commonly specified redundancy is now efficent
    virtual ~type(); // virtual requires a declaration
    type( const type &amp; ); // a simple declaration, but
};
inline type::type( const type &amp; ) = default; // now efficient
type::~type() = default; // a non-inline default definition
</code></pre>

<h4><a name="trivial">Trivial Definitions</a></h4>

<p>Critical to exploiting the benefits of
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2102.html">
N2172</a>,
an inline and explicitly-defaulted definition is trivial
if and only if the implicit definition would have been trivial.
The potential concern with out-of-class definition
is <q>How is the compiler to know if it is trivial?</q>.
The existing rule that an inline definition must occur
before any use suffices here as well.

<pre><code>
struct type
{
    type() = default; // trivial
    virtual ~type() = default; // non-trivial because virtual
    type &amp; operator =( const type &amp; ); // declaration and....
};
inline // the inline definition keeps it trivial
type &amp; type::operator =( const type &amp; ) = default;
</code></pre>

<p>Just as important, a non-inline and explicitly-defaulted definition
is <em>not</em> trivial.

<pre><code>
struct type
{
    type( const type &amp; ); // declaration and....
};
type::type( const type &amp; ) = default; // the non-inline makes it non-trivial
</code></pre>

<p>This rule enables efficient execution and concise definition
while enabling a stable binary interface to an evolving implementation.
That is, the machine-level calling sequence remains unchanged
even when the definition changes to a non-default.
For example, consider the header

<pre><code>
type.h : struct type { int x; type(); };
</code></pre>

<p>and two (mutually exclusive) definitions as the software evolves,

<pre><code>
type1.cc : type::type() = default;
type2.cc : type::type() { x = 3; }
</code></pre>

<p>In some cases, the class body can change without
requiring a change in member function definition
because the default changes with declaration of additional members.

<h4><a name="exception">Exception Specification</a></h4>

<p>Unlike the implicit default,
the explicit default has normal exception specification semantics.
This inconsistency seems at the surface to be undesireable.
The reason for the change in semantics is twofold.
First, if the explicit default used the implicit exception specification,
there would be no syntax to get back to a <q>throws anything</q> state.
Second, the users of a function
cannot tell if it is defaulted when it is non-inline,
as in the example above.
It would be undesirable to have semantics of use
change due to a change in implementation.
So, the explicit declaration needs to have the the normal
exception semantics.
Users desiring precisely the same exception specification
as the implicit declaration
must specify it.
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>
reached the same conclusion.

<h4><a name="nonimplicit">Non-Implicit Defaults</a></h4>

<p>So far, this proposal has shown
how to make explicit the implicit default definition.
There is another opportunity,
which is to use a default implementation that is not implicit.
For example,
consider the equality operator.
There is no default equality operator,
but an explicit default definition
would be able to use a standard-defined, if not implicit, default definition.

<pre><code>
struct type
{
    bool operator ==( const &amp; type ) = default;
    bool operator !=( const &amp; type ) = default;
};
</code></pre>

<p>Indeed, there are several potential operations
that could have non-implicit default implementations.
However, this paper proposes none.
We believe that at this point in the standards process,
such defaults are best left to a technical report.
However, should such a technical report be forthcoming,
the syntax is ready.


<h3><a name="delete">Delete Function Definition</a></h3>

<p>The definition form <q><code>=delete;</code></q>
indicates that the function may not be used.
However, all lookup and overload resolution
occurs before the deleted definition is noted.
That is, it is the definition that is deleted, not the symbol;
overloads that resolve to that definition are ill-formed.

<p>The primary power of this approach is twofold.
First, use of default language facilities can be made an error
by deleting the definition of functions that they require.
Second, problematic conversions can be made an error
by deleting the definition for the offending conversion
(or overloaded function).

<p>This approach of checking for a delete definition late
has two benefits.
First, it achieves the goal of making a bad overload visible.
Second, it is relativley easy to implement,
requiring no change to the already complicated lookup and overload rules.

<p>The deleted definition of a function must be its first declaration.
This rule prevents inconsistency in interpretation.

<p>The deleted definition is an inline definition,
thus requiring consistent definition throughout the program
via the one-definition rule.

<p>The deleted definition mechanism is orthogonal to access specifiers,
though accessibility is somewhat moot if the function has been deleted.

<p>Deleted functions are trivial.
This rule is necessary to obtain maximum benefit from
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2102.html">
N2172</a>.

<p>One can define a template with a deleted definition.
Specialization and argument deduction occur
as they would with a regular template function.

<p>One cannot use a deleted function in a <code>sizeof</code> expression.
We believe the existing language rules will prevent this.

<p>A deleted virtual function may not override a non-deleted virtual function
and vice-versa.

<h4><a name="features">Disabling Language Features</a></h4>

<p>The canonical example of disabling language features is disabling copying.
Simply declare the copy assignment operator and the copy constructor
with deleted definitions.
Because a declaration of any constructor disables the default constructor,
a programmer may choose to add it back with its default definition.

<pre><code>
struct type
{
    type &amp; operator =( const type &amp; ) = delete;
    type( const type &amp; ) = delete;
    type() = default;
};
</code></pre>

<p>We avoid the problem of reverse slicing identified in
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a>
because the declaration for a deleted definition still hides the
base-class copy constructor.

<p>A more subtle example involves
indirectly controlling the allocation of a type.
Deleting the definition of a class-specific <code>operator new</code>
will prevent allocation in free store
because <code>new</code> expressions
involving <code>type</code> will be ill-formed.

<pre><code>
struct type {
    void * operator new( std::size_t ) = delete;
};
</code></pre>

<p>In contrast,
deleting the definition of a destructor
will require allocation in free store
because static and automatic variables implicitly call the destructor.

<pre><code>
struct type {
    ~type() = delete; // disable destructor
};
</code></pre>

Unfortunately, the approach also prevents deleting a free-store object,
thus either limiting its use to singletons
or requiring the employment of a garbage collector.

<h4><a name="conversions">Disabling Undesired Conversions</a></h4>

<p>Removing dangerous conversions
is as important as removing undesired language defaults.

<pre><code>
struct type
{
    type( long long ); // can initialize with an long long
    type( long ) = delete; // but not anything less
};
extern void bar( type, long long ); // and the same for bad overloads
void bar( type, long ) = delete; // of free functions
</code></pre>

<p>Of considerable note
is the interaction of explicit constructors and explicit conversion operators
with deleted definitions.
(Lois Goldthwaite describes explicit conversion operators in
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1592.pdf">
<cite>N1592 Explicit Conversion Operators</cite></a>.
Michael Wong is drafting core language wording.)
The short answer is that the two facilities are orthogonal,
<code>explicit</code> controls the set of functions considered
and <code>delete</code> comments on the final choice.
The more helpful answer is a bit more subtle.
For example, consider

<pre><code>
struct type
{
    type( long long );
    explicit type( long ) = delete;
};
extern void function( type );
</code></pre>

<p>Under this proposal, lookup and the semantics of <code>explicit</code>
are unchanged,
so in the overload resoultion for <q><code>type(42)</code></q>,
42 promotes to <code>long</code> in the overload resolution,
and a deleted function is selected, which is an error.

<pre><code>
function( type( 42 ) ); // error 42 promotes to long
function( 42 ); // okay type(long long); type(long) not considered
</code></pre>

<p>In practice, <code>explicit</code> and <code>delete</code>
will probably not be used together.
Programmers desiring more restrictive diagnostics
will use <code>delete</code> alone
rather than <code>explicit</code>.


<h3><a name="comparison">Comparison to Prior Approaches</a></h3>

<p>Our solution provides all known strengths of
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1602.pdf">
N1602</a>,
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1717.pdf">
N1717</a> and
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2123.html">
N2123</a>
while avoiding many of the identified weakness.
In particular,
the <code>explicit</code> class qualifier and
the <code>prohibited</code> access specifier
would no longer be necessary.

<p>The solution addresses most of the goals of
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1890.pdf">
N1890(7)</a>,
specifically those related to function definitions,
but not those related to <q>class defaults</q> of inheritance.
We have chosen not to address class defaults for the following reasons.
<ul>
<li>Member functions can be specified virtual or pure
with very little additional syntax.
We do not believe that the syntactic savings
justifies having to look in two places for the full declaration,
which is particularly problematic for visual development environments
that wish to warp the screen to <q>the</q> definition.</li>
<li>Class inheritance and blocking virtual overrides
is better handled by some form of <q>final</q> syntax or attribute.
The current proposal is focussed on alternate function definitions,
and should leave other problems to other papers.</li>
</ul>
Our proposed syntax is more tedious than that of
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1890.pdf">
N1890(7)</a>,
but also more general,
applying to user-defined member and free functions as well.


<h2><a name="usecase">Use Case - Atomic Types</a></h2>

<p>An effective and correct definition of the atomic types in
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2145.html">
<cite>N2145 C++ Atomic Types and Operations</cite></a>
is a motivating use case for the proposal.

<p>The following code,
as defined in this proposal and in conjunction with
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2215.pdf">
N2215 Initializer lists (Rev.3)</a>,
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2230.html">
N2230 POD's Revisited; Resolving Core Issue 568 (Revison 3)</a>, and
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2235.pdf">
N2235 Generalized Constant Expressions &mdash; Revision 5</a>,
appears to satisfy the requirements of
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2007/n2145.html">
N2145</a>.

<pre><code>
typedef struct atomic_int
{
#ifdef __cplusplus
    // destructor implicitly declared and defined
    atomic_int() = default; // otherwise suppressed by other constructors
    atomic_int( int ); // construct from value
    int operator =( int __v__ ) volatile; // assign from value
    atomic_int( const atomic_int &amp; ) = delete; // too dangerous
    atomic_int &amp; operator =( const atomic_int &amp; ) = delete; // also
    operator int(); // load the value
private:
#endif
    int __f__;
} atomic_int;</code>
</code></pre>

<p> The destructor is implicitly-defaulted and trivial.
The default constructor is explicitly-defaulted and trivial.
The copy constructor and copy assignment operators are deleted
and therefore trivial.
As a result, the class is trivial and a POD,
and may therefore be used in static, aggregate initialization.

<p> The erroneous defaults for copying are deleted, preventing their use.
One can still copy from one atomic to another,
but only going through a non-atomic value,
which makes clear that a copy between two atomics is not itself atomic.

<pre><code>
atomic_int w = { 3 }; // static initialization with trivial members
atomic_int x; // default zero initialization
void function( atomic_int * p ) {
    atomic_int y( *p ); // error copy constructor is deleted
    atomic_int z( int(*p) ); // okay copy construct through value
    *p = x; // error copy assignment is deleted
    *p = int(x); // okay copy assignment through value
}
</code></pre>



<h2><a name="changes">Changes to the Standard</a></h2>

<p>We propose the following changes to the standard.
The base document is
<a href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2006/n2134.pdf">
<cite>N2134 Working Draft, Standard for Programming Language C++</cite></a>.


<h3><a name="definitions">8.4 Function definitions [dcl.fct.def]</a></h3>

<p>In paragraph 1, edit

<blockquote>
Function definitions have the form
<blockquote>
<dl>
<dt><var>function-definition:</var></dt>
<dd><var>decl-specifier-seq<sub>opt</sub>
declarator ctor-initializer<sub>opt</sub>
function-body</var></dd>
<dd><var>decl-specifier-seq<sub>opt</sub>
declarator function-try-block</var></dd>
<dd><ins><var>decl-specifier-seq<sub>opt</sub>
declarator</var> <code>&nbsp;= default ;</code></ins></dd>
<dd><ins><var>decl-specifier-seq<sub>opt</sub>
declarator</var> <code>&nbsp;= delete ;</code></ins></dd>
</dl>
</blockquote>
</blockquote>

<p>Add a new paragraph 7.

<blockquote>
A function definition of the form:
<blockquote>
<var>decl-specifier-seq<sub>opt</sub> declarator</var> <code>= default ;</code>
</blockquote>
is called an explicitly-defaulted definition;
it has exactly the implementation of an implicitly-defaulted definition
(12.1, 12.4, 12.8).
[ <em>Note</em>:
Member functions with explicitly-defaulted definitions
outside the class definition
must also be declared within the class definition.
&mdash; <em>end note</em> ]
Unlike with an implicit default definition,
the explicitly-defaulted definition may be non-inline.
[ <em>Note:</em>
Non-inline definitions are non-trivial (12.1, 12.4, 12.8).
This rule permits efficient execution and concise definition
while enabling a stable binary interface to an evolving implementation.
&mdash; <em>end note</em> ]
[ <em>Example:</em>
<blockquote><pre>
<code>struct sometype {
    sometype();
    sometype( const sometype &amp; ) = default;
    virtual ~sometype() = 0;
};
sometype::sometype() = default;
inline sometype::~sometype() = default;</code>
</pre></blockquote>
&mdash; <em>end example</em> ]
</blockquote>

<p>Add a new paragraph 8.

<blockquote>
A function definition of of the form:
<blockquote>
<var>decl-specifier-seq<sub>opt</sub> declarator</var> <code>= delete ;</code>
</blockquote>
is called a deleted definition.
A function with a deleted definition is also called a deleted function.
A deleted definition of a function
shall be the first declaration of the function.
[ <em>Example:</em>
The following code is illformed because the deleted definition
is not the first definition.
<blockquote><pre>
<code>struct sometype {
    sometype();
};
sometype::somtype() = delete;
</pre></blockquote>
&mdash; <em>end example</em> ]
A function with a deleted definition is implicitly inline.
If a function with external linkage
is defined with a deleted definition in one translation unit,
it shall be defined with a deleted definition in all translation units
in which the function is declared;
no diagnostic is required.
A function with a deleted definition shall not:
<ul>
<li>be used as the postfix expression of a function call (5.2.2), or</li>
<li>be the best viable function after overload resolution, or</li>
<li>undergo a function-to-pointer conversion, or</li>
<li>be used as an initializer (8.3.5), or</li>
<li>be the target of an implicit invocation of a function call.</li>
</ul>
[ <em>Example:</em>
One can enforce non-default initialization
and non-integral initialization with
<blockquote><pre>
<code>struct sometype {
    sometype() = delete ;
    sometype( long long ) = delete;
    sometype( double );
};
</pre></blockquote>
&mdash; <em>end example</em> ]
[ <em>Example:</em>
One can prevent use of a class in <code>new</code> expressions
with a deleted definition of a user-declared <code>operator new</code>
for that class.
<blockquote><pre>
<code>struct sometype {
    void * operator new( std::size_t ) = delete;
};
sometype * p = new sometype; // error, deleted class operator new
</pre></blockquote>
&mdash; <em>end example</em> ]
</blockquote>

<h3><a name="override">10.3 Virtual functions [class.virtual]</a></h3>

<p>At the end of the section, add a new paragraph

<blockquote>
A function with a deleted definition ([dcl.fct.def])
shall not override a function that does not have a deleted definition
Likewise, a function that does not have a deleted definition
shall not override a function with a deleted definition.
</blockquote>

<h3><a name="constructors">12.1 Constructors [class.ctor]<a></h3>

<p>Within paragraph 5, edit

<blockquote>
A default constructor is <em>trivial</em>
if it is implicitly-declared<ins>,
or explicitly-defaulted and inline,</ins>
and if:
</blockquote>

<p>Within paragraph 7, edit

<blockquote>
The implicitly-defined <ins>or explicitly-defaulted</ins> default constructor
performs the set of initializations of the class
that would be performed by a user-written default constructor for that class
with an empty <var>mem-initializer-list</var> (12.6.2)
and an empty function body.
If that user-written default constructor would be ill-formed,
the program is ill-formed.
</blockquote>

<h3><a name="destructors">12.4 Destructors [class.dtor]</a></h3>

<p>Within paragraph 3, edit

<blockquote>
A destructor is trivial if it is implicitly-declared<ins>,
or explicitly-defaulted, non-virtual and inline,</ins> and if:
</blockquote>

<p>Within paragraph 5, edit

<blockquote>
An implicitly-declared destructor is implicitly defined
when it is used to destroy an object of its class type (3.7).
A program is ill-formed if the class for which a destructor is
implicitly defined <ins>or explicitly defaulted</ins> has:
<ul>
<li>a non-static data member of class type (or array thereof) with
an inaccessible <ins>or deleted</ins> destructor, or</li>
<li>a base class with an inaccessible <ins>or deleted</ins> destructor.</li>
</ul>
</blockquote>

<h3><a name="copying">12.8 Copying class objects [class.copy]</a></h3>

<p>Within paragraph 6, edit
<blockquote>
A copy constructor for class <code>X</code> is trivial
if it is implicitly declared<ins>,
or explicitly defaulted and inline,</ins>
and if
</blockquote>

<p>Within paragraph 7, edit
<blockquote>
A program is ill-formed if the class for which a copy constructor
is implicitly defined<ins>,
or explicitly defaulted,</ins>
has:
<ul>
<li>a non-static data member of class type (or array thereof)
with an inaccessible<ins>, deleted,</ins> or ambiguous copy constructor, or</li>
<li>a base class
with an inaccessible<ins>, deleted,</ins> or ambiguous copy constructor.</li>
</ul>
</blockquote>

<p>Within paragraph 8, edit

<blockquote>
The implicitly-defined <ins>or explicitly-defaulted</ins> copy constructor
for class <code>X</code> performs a memberwise copy of its subobjects.
</blockquote>

<p>Within paragraph 11, edit

<blockquote>
A copy assignment operator for class <code>X</code> is trivial
if it is implicitly declared<ins>,
or explicitly-defaulted, non-virtual and inline,</ins>
and if
</blockquote>

<p>In paragraph 12, edit

<blockquote>
An implicitly-declared copy assignment operator
is implicitly defined when an object of its class type
is assigned a value of its class type
or a value of a class type derived from its class type.
A program is ill-formed if the class for which a
copy assignment operator is implicitly defined<ins>
or explicitly defaulted,</ins> has:
<ul>
<li>a non-static data member of const type, or</li>
<li>a non-static data member of reference type, or</li>
<li>a non-static data member of class type (or array thereof) with
an inaccessible <ins>or deleted</ins> copy assignment operator, or</li>
<li>a base class with an inaccessible copy assignment operator.</li>
</ul>
Before the implicitly-declared copy assignment operator for a class
is implicitly defined,
all implicitly-declared copy assignment operators for its direct base classes
and its non-static data members shall have been implicitly defined.
[ <em>Note:</em> an implicitly-declared copy assignment operator
has an exception-specification (15.4).
&mdash; <em>end note</em> ]
</blockquote>

<p>Within paragraph 13, edit

<blockquote>
The implicitly-defined <ins>or explicitly-defaulted</ins>
copy assignment operator for class X
performs memberwise assignment of its subobjects.
....
It is unspecified whether subobjects representing virtual base classes
are assigned more than once by the implicitly-defined
<ins>or explicitly-defaulted</ins> copy assignment operator.
</blockquote>

<p>Within paragraph 14, edit

<blockquote>
A program is ill-formed
if the copy constructor or the copy assignment operator for an object
is implicitly used and the special member function
is <ins>deleted or</ins> not accessible (clause 11).
</blockquote>

<h3><a name="address">13.4 Address of overloaded function [over.over]</a></h3>

<p>In paragraph 4, edit

<blockquote>
If more than one function is selected,
any function template specializations in the set are eliminated
if the set also contains a non-template function,
and any given function template specialization <code>F1</code>
is eliminated if the set contains a second function template specialization
whose function template is more specialized
than the function template of <code>F1</code>
according to the partial ordering rules of 14.5.5.2.
After such eliminations, if any,
there shall remain exactly one selected function.
<ins>That selected function shall not have a deleted definition
([dcl.fct.def]).</ins>

</blockquote>

</body></html>
