forked from lwg/issues
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New issue from Jiang An: "Uses-allocator construction mechanisms shou…
…ld be opted out for node handles"
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version='1.0' encoding='utf-8' standalone='no'?> | ||
<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> | ||
|
||
<issue num="4159" status="New"> | ||
<title>Uses-allocator construction mechanisms should be opted out for node handles</title> | ||
<section><sref ref="[container.node.overview]"/><sref ref="[allocator.uses.trait]"/></section> | ||
<submitter>Jiang An</submitter> | ||
<date>21 Sep 2024</date> | ||
<priority>99</priority> | ||
|
||
<discussion> | ||
<p> | ||
Currently, node handle types (<sref ref="[container.node]"/>) have the member | ||
<tt>allocator_type</tt> type alias, which makes <tt>std::uses_allocator</tt> report | ||
<tt>true</tt> for them. However, they don't have allocator-extended constructors, | ||
and it's unclear to me whether it's better to make them have such constructors. | ||
<p/> | ||
The status quo renders the following seemingly reasonable program ill-formed. | ||
</p> | ||
<blockquote><pre> | ||
#include <set> | ||
#include <map> | ||
|
||
int main() { | ||
std::pmr::set<int> s{1}; | ||
std::pmr::map<int, decltype(s)::node_type> m; | ||
m.emplace(1, s.extract(1)); | ||
} | ||
</pre></blockquote> | ||
<p> | ||
Perhaps we should consistently treat node handles not uses-allocator-constructible. | ||
</p> | ||
</discussion> | ||
|
||
<resolution> | ||
<p> | ||
This wording is relative to <paper num="N4988"/>. | ||
</p> | ||
|
||
<ol> | ||
<li><p>Modify <sref ref="[container.node.overview]"/> as indicated:</p> | ||
|
||
<blockquote> | ||
<p> | ||
[…] | ||
<p/> | ||
-4- If a user-defined specialization of <tt>pair</tt> exists for <tt>pair<const Key, T></tt> | ||
or <tt>pair<Key, T></tt>, where <tt>Key</tt> is the container's <tt>key_type</tt> and | ||
<tt>T</tt> is the container's <tt>mapped_type</tt>, the behavior of operations involving node handles | ||
is undefined. | ||
<p/> | ||
<ins>-?- For each node handle type <tt>NH</tt> and any type <tt>A</tt>, if | ||
<tt>uses_allocator<NH, A></tt> is not a program-defined specialization, it meets the | ||
<i>Cpp17BinaryTypeTrait</i> requirements (<sref ref="[meta.rqmts]"/>) and its base characteristic | ||
is <tt>false_type</tt>.</ins> | ||
</p> | ||
</blockquote> | ||
</li> | ||
</ol> | ||
</resolution> | ||
|
||
</issue> |