<html>
<head>
<title>P0942R0: Introducing a &lt;smart_ptr&gt; header</title>

<style type="text/css">
  ins { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .new { text-decoration:none; font-weight:bold; background-color:#D0FFD0 }
  del { text-decoration:line-through; background-color:#FFA0A0 }  
  strong { font-weight: inherit; color: #2020ff }
  table, td, th { border: 1px solid black; border-collapse:collapse; padding: 5px }
</style>
</head>

<body>
ISO/IEC JTC1 SC22 WG21 P0942R0<br/>
Jens Maurer &lt;Jens.Maurer@gmx.net><br/>
Target audience: LEWG, LWG<br/>
2018-02-10<br/>

<h1>P0942R0: Introducing a <code>&lt;smart_ptr&gt;</code> header</h1>

<h2>Introduction</h2>

The current <code>&lt;memory&gt;</code> header has a mix of tools for
two widely different audiences:
<ul>
  <li>smart pointers, recommended from day 1 to avoid explicit new/delete</li>
  <li>allocators and uninitialized storage, for experts</li>
</ul>

It was a mistake to mix tools for these two audiences in a single
header. I therefore suggest to introduce a new
header <code>&lt;smart_ptr&gt;</code> where all the smart pointers
live.  For backward compatibility, <code>&lt;memory&gt;</code> must
include <code>&lt;smart_ptr&gt;</code>.

<h2>Discussion</h2>

This has been raised in passing several times, so here is the paper
that actually does it.
<p>
Regarding feature testing, checking for the presence of
the <code>&lt;smart_ptr></code> header suffices.

<h2>Wording</h2>

Add <code>&lt;smart_ptr></code> to table 16 in subclause 20.5.1.2 [headers].
<p>
Create a new first subclause [smart_ptr.syn] under 23.11 [smartptr]:

<blockquote class="new">
The header <code>&lt;smart_ptr></code> defines several smart pointer
types and various function templates that operate on objects of these
types.
</blockquote>

Move all declarations for entities described in [smartptr] from
[memory.syn] to [smart_ptr.syn]:

<blockquote class="new">
<pre>
// 23.11.1, class template unique_ptr
template&lt;class T> struct default_delete;
template&lt;class T> struct default_delete&lt;T[]>;
...
// 23.11.8, atomic smart pointers
template&lt;class T> struct atomic&lt;shared_ptr&lt;T>>;
template&lt;class T> struct atomic&lt;weak_ptr&lt;T>>;
 </pre>
</blockquote>

Change 23.10.2 [memory.syn] paragraph 1 as follows:

<blockquote>
The header <code>&lt;memory></code> defines several types and function
templates that describe properties of pointers and pointer-like types,
manage memory for containers and other template types, destroy
objects, and construct multiple objects in uninitialized memory
buffers (23.10.3-23.10.11). <del>The header also defines the templates
unique_ptr, shared_ptr, weak_ptr, and various function templates that
operate on objects of these types (23.11).</del>
</blockquote>


Add a new subclause in Annex D [depr]:
<blockquote class="new">
<b>D.x Deprecated location of smart pointers [depr.memory.smartptr]</b>
<p>
    
The header <code>&lt;memory></code> has the following addition:
<pre>
  #include &lt;smart_ptr>
</pre>
</blockquote>


</body>
</html>
