-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlwg3007.html
66 lines (66 loc) · 3.15 KB
/
lwg3007.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang="en">
<head>
<title>allocate_shared should rebind allocator to cv-unqualified value_type
for construction</title>
<meta charset="utf-8">
<meta name="author" content="Glen Joseph Fernandes">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
ins { background-color: #CCFFCC; }
</style>
</head>
<body>
<p><strong>Issue Number:</strong> 3007<br>
<strong>Date:</strong> 2017-08-06<br>
<strong>Project:</strong> Programming Language C++<br>
<strong>Audience:</strong> Library Working Group<br>
<strong>Author:</strong> Glen Joseph Fernandes
(<a href="mailto:[email protected]">[email protected]</a>)</p>
<h1>allocate_shared should rebind allocator to cv-unqualified value_type for
construction</h1>
<h2>Discussion</h2>
<p>The remarks for the <code>allocate_shared</code> family of functions specify
that when constructing a (sub)object of type <code>U</code>, it uses a rebound
copy of the allocator <code>a</code> passed to <code>allocate_shared</code>
such that its <code>value_type</code> is <code>U</code>. However <code>U</code>
can be a <code>const</code> or <code>volatile</code> qualified type, and
[allocator.requirements] specify that the <code>value_type</code> must be
<em>cv</em>-unqualified.</p>
<h2>Proposed resolution</h2>
<p>This resolution is relative to N4687.</p>
<p>1. Edit 23.11.2.2.6 [util.smartptr.shared.create]/7 as indicated:</p>
<blockquote>
<p>(7.5) — When a (sub)object of a non-array type <code>U</code> is
specified to have an initial value of <code>v</code>, or <code>U(l...)</code>,
where <code>l...</code> is a list of constructor arguments,
<code>allocate_shared</code> shall initialize this (sub)object via the
expression</p>
<ol style="list-style-type:none">
<li><p>(7.5.1) —
<code>allocator_traits<A2>::construct(a2, pv, v)</code> or</p></li>
<li><p>(7.5.2) —
<code>allocator_traits<A2>::construct(a2, pv, l...)</code></p></li>
</ol>
<p>respectively, where <code>pv</code> points to storage suitable to hold an
object of type <code>U</code> and <code>a2</code> of type <code>A2</code> is a
rebound copy of the allocator a passed to <code>allocate_shared</code> such
that its <code>value_type</code> is
<code><ins>remove_cv_t<</ins>U<ins>></ins></code>.</p>
<p>(7.6) — When a (sub)object of non-array type <code>U</code> is
specified to have a default initial value, <code>make_shared</code> shall
initialize this (sub)object via the expression <code>::new(pv) U()</code>,
where <code>pv</code> has type <code>void*</code> and points to storage
suitable to hold an object of type <code>U</code>.</p>
<p>(7.7) — When a (sub)object of non-array type <code>U</code> is
specified to have a default initial value, <code>allocate_shared</code> shall
initialize this (sub)object via the expression
<code>allocator_traits<A2>::construct(a2, pv)</code>, where
<code>pv</code> points to storage suitable to hold an object of type
<code>U</code> and <code>a2</code> of type <code>A2</code> is a rebound copy of
the allocator a passed to <code>allocate_shared</code> such that its
<code>value_type</code> is
<code><ins>remove_cv_t<</ins>U<ins>></ins></code>.</p>
</blockquote>
</body>
</html>