Specify the exception safety of emplace in more detail

This commit is contained in:
Peter Dimov
2019-03-30 20:26:13 +02:00
parent 89986c7634
commit 2e8ae0c796
2 changed files with 48 additions and 6 deletions

View File

@ -1367,7 +1367,23 @@ value as if using the expression <code>Ti(std::forward&lt;A&gt;(a)&#8230;&#8203;
</dd>
<dt class="hdlist1">Exception Safety: </dt>
<dd>
<p>Basic. On exception the value of the variant is valid but unspecified.</p>
<p>On exception:</p>
<div class="ulist">
<ul>
<li>
<p>If the list of alternatives contains <code>monostate</code>, the contained value
is either unchanged, or <code>monostate{}</code>;</p>
</li>
<li>
<p>Otherwise, if the list of alternatives contains types for which
<code>is_nothrow_default_constructible_v</code> is <code>true</code>, the contained value
is either unchanged, or <code>Tj{}</code>, where <code>Tj</code> is the first such alternative;</p>
</li>
<li>
<p>Otherwise, the contained value is unchanged.</p>
</li>
</ul>
</div>
</dd>
<dt class="hdlist1">Remarks: </dt>
<dd>
@ -1415,7 +1431,23 @@ value as if using the expression <code>Ti(il, std::forward&lt;A&gt;(a)&#8230;&#8
</dd>
<dt class="hdlist1">Exception Safety: </dt>
<dd>
<p>Basic. On exception the value of the variant is valid but unspecified.</p>
<p>On exception:</p>
<div class="ulist">
<ul>
<li>
<p>If the list of alternatives contains <code>monostate</code>, the contained value
is either unchanged, or <code>monostate{}</code>;</p>
</li>
<li>
<p>Otherwise, if the list of alternatives contains types for which
<code>is_nothrow_default_constructible_v</code> is <code>true</code>, the contained value
is either unchanged, or <code>Tj{}</code>, where <code>Tj</code> is the first such alternative;</p>
</li>
<li>
<p>Otherwise, the contained value is unchanged.</p>
</li>
</ul>
</div>
</dd>
<dt class="hdlist1">Remarks: </dt>
<dd>

View File

@ -504,8 +504,13 @@ Ensures: :: `index() == I`.
Returns: :: A reference to the new contained value.
Throws: ::
Nothing unless the initialization of the new contained value throws.
Exception Safety: ::
Basic. On exception the value of the variant is valid but unspecified.
Exception Safety: :: On exception:
- If the list of alternatives contains `monostate`, the contained value
is either unchanged, or `monostate{}`;
- Otherwise, if the list of alternatives contains types for which
`is_nothrow_default_constructible_v` is `true`, the contained value
is either unchanged, or `Tj{}`, where `Tj` is the first such alternative;
- Otherwise, the contained value is unchanged.
Remarks: ::
This function shall not participate in overload resolution unless
`std::is_constructible_v<Ti, A...>` is `true`.
@ -526,8 +531,13 @@ Ensures: :: `index() == I`.
Returns: :: A reference to the new contained value.
Throws: ::
Nothing unless the initialization of the new contained value throws.
Exception Safety: ::
Basic. On exception the value of the variant is valid but unspecified.
Exception Safety: :: On exception:
- If the list of alternatives contains `monostate`, the contained value
is either unchanged, or `monostate{}`;
- Otherwise, if the list of alternatives contains types for which
`is_nothrow_default_constructible_v` is `true`, the contained value
is either unchanged, or `Tj{}`, where `Tj` is the first such alternative;
- Otherwise, the contained value is unchanged.
Remarks: ::
This function shall not participate in overload resolution unless
`std::is_constructible_v<Ti, std::initializer_list<V>&, A...>` is `true`.