Skip to content

Commit a655425

Browse files
committed
New issue from Jonathan: hive::splice can throw bad_alloc
1 parent 8099dc4 commit a655425

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

xml/issue4467.xml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4467" status="New">
5+
<title>`hive::splice` can throw `bad_alloc`</title>
6+
<section><sref ref="[hive.operations]"/></section>
7+
<submitter>Jonathan Wakely</submitter>
8+
<date>08 Nov 2025</date>
9+
<priority>99</priority>
10+
11+
<discussion>
12+
<p>
13+
Moving blocks from the source `hive` to the destination `hive` might require
14+
reallocating the array of pointers to blocks, so the <i>Throws</i>: element
15+
should allow this.
16+
</p>
17+
</discussion>
18+
19+
<resolution>
20+
<p>
21+
This wording is relative to <paper num="N5014"/>.
22+
</p>
23+
24+
<ol>
25+
<li><p>Modify <sref ref="[hive.operations]"/>, as indicated:</p>
26+
<blockquote>
27+
<pre>
28+
void splice(hive&amp; x);
29+
void splice(hive&amp;&amp; x);
30+
</pre>
31+
<blockquote>
32+
<p>-2- <i>Preconditions</i>:
33+
`get_allocator() == x.get_allocator()` is `true`.
34+
</p>
35+
<p>-3- <i>Effects</i>:
36+
If `addressof(x) == this` is `true`,
37+
the behavior is erroneous and there are no effects.
38+
Otherwise, inserts the contents of `x` into `*this` and `x` becomes empty.
39+
Pointers and references to the moved elements of `x` now refer to those same
40+
elements but as members of `*this`.
41+
Iterators referring to the moved elements continue to refer to their elements,
42+
but they now behave as iterators into `*this`, not into `x`.
43+
</p>
44+
<p>-4- <i>Throws</i>:
45+
`length_error` if any of `x`'s active blocks are not within the bounds of
46+
<i>`current-limits`</i>.
47+
<ins>
48+
Any exception thrown by the allocator.
49+
</ins>
50+
</p>
51+
<p>-5- <i>Complexity</i>:
52+
Linear in the sum of all element blocks in `x`
53+
plus all element blocks in `*this`.
54+
</p>
55+
<p>-6- <i>Remarks</i>: Reserved blocks in `x` are not transferred into `*this`.
56+
If `addressof(x) == this` is `false`,
57+
invalidates the past-the-end iterator for both `x` and `*this`.
58+
</p>
59+
</blockquote>
60+
</blockquote>
61+
</li>
62+
</ol>
63+
64+
</resolution>
65+
66+
</issue>

0 commit comments

Comments
 (0)