<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<html>
<style type="text/css">
  ins, ins * { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  del, del * { text-decoration:line-through; background-color:#FFA0A0 }
  #hidedel:checked ~ * del, #hidedel:checked ~ * del * { display:none; visibility:hidden }

blockquote {
  padding: .5em;
  border: .5em;
  border-color: silver;
  border-left-style: solid;
}

blockquote.std { color: #000000; background-color: #F1F1F1;
  border: 1px solid #D1D1D1;
  padding-left: 0.5em; padding-right: 0.5em; }
blockquote.stdins { text-decoration: underline;
  color: #000000; background-color: #C8FFC8;
  border: 1px solid #B3EBB3; padding: 0.5em; }
blockquote.stddel { text-decoration: line-through;
  color: #000000; background-color: #FFEBFF;
  border: 1px solid #ECD7EC;
  padding-left: 0.5em; padding-right: 0.5em; }

p.grammarlhs { margin-bottom: 0 }
p.grammarrhs { margin-left:8em; margin-top:0; margin-bottom:0; text-indent:-4em }

div.wrapper {
    max-width: 60em;
    margin: auto;
}

a { text-decoration: none; }

a.hidden_link {
    text-decoration: none;
    color: inherit;
}

li {
    margin-top: 0.0em;
    margin-bottom: 0.0em;
}

h1 { line-height: 1; }
h2 { line-height: 1; }
h3 { line-height: 1; }
h4 { line-height: 1; }

:target { background-color: #C9FBC9; }
:target .codeblock { background-color: #C9FBC9; }
:target ul { background-color: #C9FBC9; }

.abbr_ref { float: right; }

.folded_abbr_ref { float: right; }
:target .folded_abbr_ref { display: none; }

:target .unfolded_abbr_ref { float: right; display: inherit; }
.unfolded_abbr_ref { display: none; }

.secnum { display: inline-block; min-width: 35pt; }
.annexnum { display: block; }

div.sourceLinkParent {
    float: right;
}

a.sourceLink {
    position: absolute;
    opacity: 0;
    margin-left: 10pt;
}

a.sourceLink:hover {
    opacity: 1;
}

div.marginalizedparent {
    position: relative;
    left: -5em;
}

div.footnoteNumberParent {
    position: relative;
    left: -4.7em;
}

a.marginalized {
    position: absolute;
    font-size: 75%;
    text-align: right;
    width: 5em;
}

a.enumerated_item_num {
    position: relative;
    left: -3.5em;
    display: inline-block;
    margin-right: -3em;
    text-align: right;
    width: 3em;
}

div.para { margin-bottom: 0.6em; margin-top: 0.6em; text-align: justify; }
div.section { text-align: justify; }
div.sentence { display: inline; }

span.indexparent {
    display: inline;
    position: relative;
    float: right;
    right: -1em;
}

a.index {
    position: absolute;
    display: none;
}

a.index:before { content: "Ã¢Å¸Âµ"; }
    /* this way the content is not selectable */

a.index:target {
    display: inline;
}

.indexitems {
    margin-left: 2em;
    text-indent: -2em;
}

div.itemdescr {
    margin-left: 3em;
}

.bnf {
    font-family: serif;
    margin-left: 40pt;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.ncbnf {
    font-family: serif;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 40pt;
}

.bnftab {
    font-family: serif;
    font-style: italic;
    margin-left: 40pt;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.ncsimplebnf {
    font-family: serif;
    font-style: italic;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 40pt;
}

.ncbnftab {
    font-family: serif;
    font-style: italic;
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 40pt;
}

.bnfkeywordtab {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
    margin-left: 40pt;
}

span.textnormal {
    font-style: normal;
    font-family: serif;
    white-space: normal;
    display: inline-block;
}

span.descr { font-style: normal; font-family: serif; }
span.grammarterm { font-style: italic; }
span.term { font-style: italic; }
span.terminal { font-family: monospace; font-style: normal; }
span.nonterminal { font-style: italic; }
span.tcode { font-family: monospace; font-style: normal; }
span.textbf { font-weight: bold; }
span.textsc { font-variant: small-caps; }
a.nontermdef { font-style: italic; font-family: serif; }
span.emph { font-style: italic; }
span.techterm { font-style: italic; }
span.mathit { font-style: italic; }
span.mathsf { font-family: sans-serif; }
span.mathrm { font-family: serif; font-style: normal; }
span.textrm { font-family: serif; }
span.textsl { font-style: italic; }
span.mathtt { font-family: monospace; font-style: normal; }
span.mbox { font-family: serif; font-style: normal; }
span.ungap { display: inline-block; width: 2pt; }
span.textit { font-style: italic; }
span.texttt { font-family: monospace; }
span.tcode_in_codeblock { font-family: monospace; font-style: normal; }

span.phantom { color: white; }
span.math { }

span.mathblock {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 1.2em;
    margin-bottom: 1.2em;
    text-align: center;
}

span.mathalpha {
    font-style: italic;
}

span.synopsis {
    font-weight: bold;
    margin-top: 0.5em;
    display: block;
}

span.definition {
    font-weight: bold;
    display: block;
}

span.keyword {
  color: #00607c;
  font-style: normal;
}

.codeblock {
  font-family: Courier New;
  margin-left: 1.2em;
  line-height: 140%;
  font-size: 10pt;
  white-space: pre;
  display: block;
  margin-top: 3pt;
  margin-bottom: 3pt;
  overflow: auto;
  margin-right: -15mm;
}

code {
    font-family: monospace;
    font-style: normal;
}

code.itemdecl {
    margin-top: 2ex;
    white-space: pre;
    display: block;
}

code.itemdeclcode {
    white-space: pre;
    font-family: Courier New;
    font-size: 10pt;
    display: block;
    overflow: auto;
    margin-right: -15mm;
}

.comment {
    font-style: italic;
    font-family: serif;
}

span.textsuperscript {
    vertical-align: super;
    font-size: smaller;
    line-height: 0;
}

.footnotenum { vertical-align: super; font-size: smaller; line-height: 0; }

.footnote {
    font-size: small;
    margin-left: 2em;
    margin-right: 2em;
    margin-top: 0.6em;
    margin-bottom: 0.6em;
}

div.minipage {
    display: inline-block;
    margin-right: 3em;
}

div.numberedTable {
    text-align: center;
    margin: 2em;
}

div.figure {
    text-align: center;
    margin: 2em;
}

table {
    border: 1px solid black;
    border-collapse: collapse;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0.8em;
    text-align: left;
    hyphens: none; /* otherwise some columns get very narrow, e.g. [tab:hash] */
}

td, th {
    padding-left: 1em;
    padding-right: 1em;
    vertical-align: top;
}

td.left {
    text-align: left;
}

td.right {
    text-align: right;
}

td.center {
    text-align: center;
}

td.justify {
    text-align: justify;
}

td.border {
    border-left: 1px solid black;
}

tr.rowsep, td.cline {
    border-top: 1px solid black;
}

tr.capsep {
    border-top: 3px solid black;
    border-top-style: double;
}

th {
    border-bottom: 1px solid black;
}

span.centry {
    font-weight: bold;
}

div.table {
    display: block;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    width: 90%;
}

span.indented {
    display: block;
    margin-left: 2em;
    margin-bottom: 1em;
    margin-top: 1em;
}
</style>

<title>P2407R4: Freestanding Library: Partial Classes</title>
<body>
<h1>Freestanding Library: Partial Classes</h1>
Document number: P2407R4<br/>
Date: 2023-06-28<br/>
Reply-to:<br/>
&emsp;&emsp;Ben Craig &lt;ben dot craig at gmail dot com&gt;<br/>
&emsp;&emsp;Emil Meissner &lt;e dot meissner at seznam dot cz&gt;<br/>
Audience: Library Working Group

<h1>Changes from previous revisions</h1>
<h3>Changes from R3</h3>
<ul>
  <li>Added <code>fill_n</code> and <code>swap_ranges</code> from <code>&lt;algorithm&gt;</code></li>
  <li><code>optional</code> now specified in terms of <code>**this</code> instead of <code>.value()</code></li>
  <li><code>variant</code> now specified in terms of <code>get_if</code> instead of <code>get</code></li>
  <li><code>string_view</code> find / search operations now specified in terms of <code>data_</code> instead of <code>at()</code></li>
  <li>Added missing parenthesis on <code>size()</code> call in <code>string_view::ends_with</code></li>
  <li>Made feature test macros <code>// freestanding</code></li>
  <li>More deliberate with use of "synopsis" vs. "header synopsis"</li>
  <li>freestanding-deleted and freestanding-partial are now freestanding items with altered requirements</li>
  <li>Added notes stating overload resolution consequences of <code>// hosted</code> vs. <code>// freestanding-deleted</code></li>
  <li>More explicitly making the members of freestanding items also be freestanding items</li>
  <li>Deleted note discussing implication of having the same requirements, as those are covered more explicitly now</li>
</ul>
<h3>Changes from R2</h3>
<ul>
  <li><code>// freestanding-delete</code> to <code><i>// freestanding-deleted</i></code></li>
  <li>Adding <code>bad_optional_access</code> per LWG's request for consistency</li>
  <li>Rewording <code>string_view::starts_with</code> and <code>string_view::ends_with</code> in terms of freestanding functions</li>
  <li>Avoiding word "item" in instructions to the editor</li>
  <li>Made example in wording use <code><i>// freestanding-deleted</i></code></li>
  <li>Added <code><i>// mostly freestanding</i></code> header marker</li>
</ul>
<h3>Changes from R1</h3>
<ul>
  <li>Ported paper to HTML</li>
  <li>Only annotating the deleted parts of partial classes, and not the included parts</li>
  <li>Mentioning forward_like in relation to variant's value categories</li>
  <li>New prose for [freestanding.item]</li>
</ul>
<h3>Changes from R0</h3>
<ul>
  <li>Add wording for feature test macros</li>
  <li>Mention monadic optional and <code>string_view::contains</code></li>
</ul>

<h1>Introduction</h1>
This proposal is part of a group of papers aimed at improving the state of freestanding.
It marks (parts of) std::array, std::string_view, std::variant, and std::optional as such.
A future paper might add std::bitset (as was the original goal in [P2268R0])

<h1>Motivation and Scope</h1>
<p>
All of the added classes are fundamentally compatible with freestanding, except for a few methods that throw (e.g. array::at).
We explicitly =delete these undesirable methods.
</p><p>
The main driving factor for these additions is the immense usefulness of these types in practice.
</p>

<h2>Scope</h2>
We refine [freestanding.item] by specifying the notion of partial classes, and accordingly specify the newly (partially) freestanding classes as such.

<h3>About &lt;bitset&gt;</h3>
As mentioned in the introduction, this paper does not deal with bitset.
Bitset is unique in that a relatively big part of its interface depends on std::basic_string.
We do not currently have a sound plan to make bitset work as nicely as we’d like to.
This situation is made worse by a significant amount of bitset’s member functions that throw.

<h2>Implementation experience</h2>
<h3>The Existing Standard Library</h3>
We’ve forked libc++, and =deleted all not freestanding methods.
Except for some methods on string_view (which are implemented in terms of the deleted string_view::substring), this did not require any changes in the implementation.
All test cases (except for the deleted methods) passed after some rather minor adjustments (e.g. replacing get<0>(v) with *get_if<0>(&v)), confirming that all these types are usable without the deleted methods.

<h3>In Practice</h3>
<p>
Since we aren’t changing the semantics of any of the classes (except deleted non-critical methods), it is fair to say that all of the (implementer and user) experience gathered as part of hosted applies the same to freestanding.
</p><p>
The only question is, whether these classes are compatible with freestanding.
To which the answer is yes! For example, the [Embedded Template Library] offers direct mappings of the std types.
Even in kernel-level libraries, like Serenity’s [AK] use a form of these utilities.
</p>

<h1>Design decisions</h1>
<h2>Deleting behavior</h2>
<p>
Our decision to delete methods we can’t mark as freestanding was made to keep overload resolution the same on freestanding as hosted.
</p><p>
An additional benefit here is, that users of these classes, who might expect to use a throwing method, which was not provided by the implementation, will get a more meaningful error than the method simply missing.
This also means we can keep options open for reintroducing the deleted functions into freestanding.
(e.g. operator&lt;&lt;(ostream, string_view), should &lt;ostream&gt; be added).
</p>

<h2><a href="https://eel.is/c++draft/conventions">[conventions]</a> changes</h2>
<p>
The predecessor to this paper used <code>//freestanding, partial</code> to mean a class (template) is only required to be partially implemented, in conjunction with <code>//freestanding, omit</code> meaning a declaration is not in freestanding.
</p><p>
In this paper, we mark not fully freestanding classes templates as <code>// freestanding-partial</code>, and use P2338's <code>// freestanding-deleted</code> to mark which pieces of the class should be omitted.
We no longer annotate all the class members, favoring terseness over explicitness.
</p>

<h2>On std::visit</h2>
<p>
In this paper, we mark std::visit as freestanding, even though it is theoretically throwing.
However, the conditions for std::visit to throw are as follows:
</p><p>
It is possible for a variant to hold no value if an exception is thrown during a type-changing assignment or emplacement.
</p><p>
This means a variant will only throw on visit if a user type throws (library types don’t throw on freestanding).
In this case, std::visit throwing isn’t a problem, since the user’s code is already using, and (hopefully) handling
exceptions.
</p><p>
This however has the unfortunate side-effect that we need to keep bad_variant_access freestanding.
</p>

<h2>Notes on variant and value categories</h2>
<p>
By getting rid of std::get, we force users to use std::get_if.
Since std::get_if returns a pointer, one can only access the value of a variant by dereferencing said pointer, obtaining an lvalue, discarding the value category of the held object.
This is unlikely to have an impact on application code, but might impact highly generic library code.
</p><p>
std::forward_like can help in these cases.
The value category of the variant can be transferred to the dereferenced pointer returned from set::get_if.
</p>

<h1>Justification for deletions</h1>
Every deleted method is throwing.
We omit string_view’s associated operator&lt;&lt; since we don’t add basic_ostream.

<h1>Monadic optional and string_view::contains</h1>
Since this paper was first published, std::string_view got a new contains member function, and std::optional got transform, and_then, and or_else.
All these functions are not throwing, and there are no other problems regarding freestanding.
We therefore opt for them being marked as freestanding.

<h1>Minimal <code>&lt;algorithm&gt;</code> inclusions</h1>
<code>std::array::fill</code> is specified in terms of <code>std::fill_n</code>.
<code>std::array::swap</code> is specified in terms of <code>std::swap_ranges</code>.
Both <code>fill_n</code> and <code>swap_ranges</code> are reasonable inclusions in freestanding.
Rather than respecify <code>array</code> in terms of other freestanding facilities, we have chosen to pull in the functions from <code>&lt;algorithm&gt;</code> that we need.
A later paper will likely add many more facilities from <code>&lt;algorithm&gt;</code>.

An email on the LEWG reflector in June 2023 asked to add <code>std::fill_n</code> and <code>std::swap_ranges</code>.
The request received eleven +1's, and no opposition to this change.
The authors did not vote on the reflector poll.

<h1>Wording</h1>
This paper’s wording is based on the working draft, <a href="https://wg21.link/N4950">[N4950]</a>,
plus the anticipated inclusion of merging <a href="https://wg21.link/P2198R6">[P2198R6] (Freestanding Feature-Test Macros and Implementation-Defined Extensions)</a> and
<a href="https://wg21.link/P2338R4">[P2338R4] (Freestanding Library: Character primitives and the C library)</a>.

<h2>Change in <a href="https://eel.is/c++draft/freestanding.item">[freestanding.item]</a></h2>
Modify <a href="https://eel.is/c++draft/freestanding.item">[freestanding.item]</a>.
This includes a reordering of what was paragraph 6.

<blockquote class="std">
<div class='para'>
    <div class='marginalizedparent'><a class='marginalized'>2</a></div>
    <div class='sentence'>Unless otherwise specified,
        the requirements on freestanding items for a freestanding implementation
        are the same as the corresponding requirements for a hosted implementation,
        except that not all of the members of the namespaces are required to be present.
    </div>
    <del>
    <div class='note'>
        [<i>Note&nbsp;1</i>:
        
        <div class='sentence'>This implies that freestanding item enumerations have the same enumerators on
            freestanding implementations and hosted implementations.
        </div>
        <div class='sentence'>Furthermore, class types have the same members and
            class templates have the same deduction guides
            on freestanding implementations and hosted implementations.
        </div>
        
         —&nbsp;<i>end note</i>]
    </div>
    </del>
</div>

<div class='para'>
    <div class='marginalizedparent'><a class='marginalized'><del>6</del><ins>?</ins></a></div>
    <div class='sentence'>Function declarations and function template declarations followed by
        a comment that include <span class='textit'>freestanding-deleted</span> are 
        <span class='textit'>freestanding deleted functions</span>.</div>
    <div class='sentence'>On freestanding implementations, it is implementation
        defined whether each function definition introduced by a freestanding deleted function
        is <del>a freestanding item or </del>a deleted function
        (<a href="https://wg21.link/dcl.fct.def.delete">[dcl.fct.def.delete]</a>)<ins> or whether the
        requirements are the same as the corresponding requirements for a hosted implementation.</ins>.</div>
    <ins>
    <div class="note">[ <span class="textit">Note</span><span class="textit">:</span>
        Deleted definitions ensure that overload resolution
        does not silently change when migrating a library from a freestanding implementation
        to a hosted implementation. -<i>end note</i>]
    </div>
    </ins>
    <div class='example'>[  <span class='textit'>Example:</span>
<pre class='codeblock'>
double abs(double j); <span class='comment'>// <span class='textit'>freestanding-deleted</span></span>
</pre>
    -<i>end example</i>]
    </div>
</div>

<ins>
<div class='para'>
    <div class='marginalizedparent'><a class='marginalized'>?</a></div>
    <div class='sentence'>A class type declaration or class template declaration in a synopsis
        that is followed by a comment that includes <span class='textit'>freestanding-partial</span>
        is a freestanding item, except that it contains at least one freestanding deleted function.</div>
    <div class='example'>[  <span class='textit'>Example:</span>
<pre class='codeblock'>
template &lt;class T, size_t N&gt; struct array; <span class='comment'>//<span class='textit'>freestanding-partial</span></span>

template&lt;class T, size_t N&gt;
struct array {
  constexpr reference       operator[](size_type n);
  constexpr const_reference operator[](size_type n) const;
  constexpr reference       at(size_type n); <span class='comment'>//<span class='textit'>freestanding-deleted</span></span>
  constexpr const_reference at(size_type n) const; <span class='comment'>//<span class='textit'>freestanding-deleted</span></span>
};
</pre>
    -<i>end example</i>]</div>
</div>
</ins>

<div class='para'>
    <div class='marginalizedparent'><a class='marginalized'>3</a></div>
    <div class="sentence">A declaration in a <del>header </del>synopsis is a freestanding item if
        <ul class="itemize">
            <li><div class="marginalizedparent" style="left:-27mm"><a class="marginalized">(3.1)</a></div>
                it is followed by a comment that includes <i>freestanding</i>,<del> or</del>
            </li>
            <ins>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(3.?)</a></div>
                it is followed by a comment that includes <i>freestanding-deleted</i>,
            </li>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(3.?)</a></div>
                it is followed by a comment that includes <i>freestanding-partial</i>,
            </li>
            </ins>
            <li><div class="marginalizedparent" style="left:-27mm"><a class="marginalized">(3.2)</a></div>
                the header synopsis begins with a comment that includes <i>all freestanding</i><del>.</del><ins>, or</ins>
            </li>
            <ins>
                <li><div class="marginalizedparent" style="left:-27mm"><a class="marginalized">(3.?)</a></div>
                    the header synopsis begins with a comment that includes <i>mostly freestanding</i> and the declaration is not followed by a comment that includes <i>hosted</i>.
                    <div class="note">[ <span class="textit">Note</span><span class="textit">:</span>
                        Declarations followed by <i>hosted</i> in <i>mostly freestanding</i> headers are not freestanding items.
                        Overload resolution with such functions could vary between hosted and freestanding implementations. -<i>end note</i>]
                    </div>
                </li>
            </ins>
        </ul>
    </div>
</div>

<div class='para'>
    <div class='marginalizedparent'><a class='marginalized'>4</a></div>
    <div class='sentence'>An entity<ins>, deduction guide,</ins> or <i>typedef-name</i> is a freestanding item if it is:
        <ul class='itemize'>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.1)</a></div>
                introduced by a declaration that is a freestanding item,
            </li>
            <ins>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.?)</a></div>
                a member of a freestanding item,
            </li>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.?)</a></div>
                an enumerator of a freestanding item,
            </li>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.?)</a></div>
                a deduction guide of a freestanding item,
            </li>
            </ins>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.2)</a></div>
                an enclosing namespace of a freestanding item,
            </li>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.3)</a></div>
                a friend of a freestanding item,
            </li>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.4)</a></div>
                denoted by a <i>typedef-name</i> that is a freestanding item, or
            </li>
            <li><div class='marginalizedparent' style='left:-27mm'><a class="marginalized">(4.5)</a></div>
                denoted by an alias template that is a freestanding item.
            </li>
        </ul>
    </div>
</div>

<div class='para'>
    <div class='marginalizedparent'><a class='marginalized'>5</a></div>
    <div class="sentence">A macro is a freestanding item if it is defined in a header synopsis and
        <ul class="itemize">
            <li><div class="marginalizedparent" style="left:-27mm"><a class="marginalized">(5.1)</a></div>
                the definition is followed by a comment that includes <i>freestanding</i>,<del> or</del>
            </li>
            <li><div class="marginalizedparent" style="left:-27mm"><a class="marginalized">(5.2)</a></div>
                the header synopsis begins with a comment that includes <i>all freestanding</i><del>.</del><ins>, or</ins>
            </li>
            <ins>
                <li><div class="marginalizedparent" style="left:-27mm"><a class="marginalized">(5.?)</a></div>
                    the header synopsis begins with a comment that includes <i>mostly freestanding</i> and the definition is not followed by a comment that includes <i>hosted</i>.
                </li>
            </ins>
        </ul>
    </div>
</div>

</blockquote>

<h2>Changes in <a href="https://eel.is/c++draft/compliance">[compliance]</a></h2>
Add new rows to the "C++ headers for freestanding implementations" table:
<table style="border: 1px solid black">
<thead>
<tr style="border: 1px solid black">
<th colspan="2" style="text-align: center">Subclause</th><th style="text-align: center">Header(s)</th>
</tr>
</thead>
<tbody>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex">[&hellip;]</td>
<td style="padding: 0ex 1ex 0ex 1ex">[&hellip;]</td>
<td style="padding: 0ex 1ex 0ex 1ex">[&hellip;]</td>
</tr>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex"><ins>?.? <a href="https://wg21.link/optional">[optional]</a></ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins>Optional objects</ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins><tt>&lt;optional&gt;</tt></ins></td>
</tr>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex"><ins>?.? <a href="https://wg21.link/variant">[variant]</a></ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins>Variants</ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins><tt>&lt;variant&gt;</tt></ins></td>
</tr>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex"><ins>?.? <a href="https://wg21.link/string.view">[string.view]</a></ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins>String view classes</ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins><tt>&lt;string_view&gt;</tt></ins></td>
</tr>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex"><ins>?.? <a href="https://wg21.link/array">[array]</a></ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins>Class template <code>array</code></ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins><tt>&lt;array&gt;</tt></ins></td>
</tr>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex"><ins>?.? <a href="https://wg21.link/algorithms">[algorithms]</a></ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins>Algorithms library</ins></td>
<td style="padding: 0ex 1ex 0ex 1ex"><ins><tt>&lt;algorithm&gt;</tt></ins></td>
</tr>
<tr style="border: 1px solid black">
<td style="padding: 0ex 1ex 0ex 1ex">[&hellip;]</td>
<td style="padding: 0ex 1ex 0ex 1ex">[&hellip;]</td>
<td style="padding: 0ex 1ex 0ex 1ex">[&hellip;]</td>
</tr>
</tbody>
</table>

<h2>Changes in <a href="https://eel.is/c++draft/version.syn">[version.syn]</a></h2>
This part of the paper follows the guide lines as specified in [P2198R6].
Instructions to the editor:<br/>
Add the following macros to <a href="https://eel.is/c++draft/version.syn">[version.syn]</a>:
<blockquote class="stdins">
<pre class='codeblock'>
#define __cpp_lib_freestanding_algorithm 20XXXXL   // freestanding, also in &lt;algorithm&gt;
#define __cpp_lib_freestanding_array 20XXXXL       // freestanding, also in &lt;array&gt;
#define __cpp_lib_freestanding_optional 20XXXXL    // freestanding, also in &lt;optional&gt;
#define __cpp_lib_freestanding_string_view 20XXXXL // freestanding, also in &lt;string_view&gt;
#define __cpp_lib_freestanding_variant 20XXXXL     // freestanding, also in &lt;variant&gt;
</pre>
</blockquote>

<h2>Changes in <a href="https://eel.is/c++draft/optional.syn">[optional.syn]</a></h2>
Instructions to the editor:<br/>
<p>
Please insert a <code><i>// mostly freestanding</i></code> comment at the beginning of the <a href="https://eel.is/c++draft/optional.syn">[optional.syn]</a> synopsis.<br/>
</p>
Please append a <code><i>// freestanding-partial</i></code> comment to the following declaration:
<ul>
  <li><code>optional</code></li>
</ul>

<h2>Changes in <a href="https://eel.is/c++draft/optional.optional.general">[optional.optional.general]</a></h2>
<p>
Instructions to the editor:
</p><p>
Please append a <code><i>// freestanding-deleted</i></code> comment to every overload of <code>value</code>.
</p>

<h2>Changes in <a href="https://eel.is/c++draft/optional.monadic">[optional.monadic]</a></h2>
<p>

<blockquote class="std">

<code class="itemdeclcode">
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> and_then(F&amp;&amp; f) &amp;;
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> and_then(F&amp;&amp; f) <span class="keyword">const</span> &amp;;
</code>

<div class="para" id="1">
    <div class="marginalizedparent"><a class="marginalized" href="#1">1</a></div>
    <div class="itemdescr"><div class="texpara"><div id="1.sentence-1" class="sentence">
        Let <span class="texttt">U</span> be <span class="texttt">invoke_result_t&lt;F, <span class="keyword">decltype</span>
        (<del>value()</del><ins>**<span class="keyword">this</span></ins>)&gt;</span>.
    </div></div></div>
</div>

<div class="para" id="2">
    <div class="marginalizedparent"><a class="marginalized" href="#2">2</a></div>
    <div class="itemdescr"><div class="texpara"><div id="2.sentence-1" class="sentence">
            <i>Mandates</i>: <span class="texttt">remove_cvref_t&lt;U&gt;</span> is a specialization of <span class="texttt">optional</span>.
    </div></div></div>
</div>

<div class="para" id="3">
    <div class="marginalizedparent"><a class="marginalized" href="#3">3</a></div>
    <div class="itemdescr"><div class="texpara"><div id="3.sentence-1" class="sentence">
        <i>Effects</i>: Equivalent to:
<span class="codeblock"><span class="keyword">if</span> (*<span class="keyword">this</span>) <span class="curlybracket">{</span>
  <span class="keyword">return</span> invoke(std::forward&lt;F&gt;(f), <del>value()</del><ins>**<span class="keyword">this</span></ins>);
<span class="curlybracket">}</span> <span class="keyword">else</span> <span class="curlybracket">{</span>
  <span class="keyword">return</span> remove_cvref_t&lt;U&gt;();
<span class="curlybracket">}</span></span>
    </div></div></div>
</div>

<code class="itemdeclcode">
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> and_then(F&amp;&amp; f) &amp;&amp;;
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> and_then(F&amp;&amp; f) <span class="keyword">const</span> &amp;&amp;;
</code>

<div class="para" id="4">
    <div class="marginalizedparent"><a class="marginalized" href="#4">4</a></div>
    <div class="itemdescr"><div class="texpara"><div id="4.sentence-1" class="sentence">
        Let <span class="texttt">U</span> be <span class="texttt">invoke_result_t&lt;F, <span class="keyword">decltype</span>(std::move(<del>value()</del><ins>**<span class="keyword">this</span></ins>))&gt;</span>.
    </div></div></div>
</div>

<div class="para" id="5">
    <div class="marginalizedparent"><a class="marginalized" href="#5">5</a></div>
    <div class="itemdescr"><div class="texpara"><div id="5.sentence-1" class="sentence">
        <i>Mandates</i>: <span class="texttt">remove_cvref_t&lt;U&gt;</span> is a specialization of <span class="texttt">optional</span>.
    </div></div></div>
</div>

<div class="para" id="6">
    <div class="marginalizedparent"><a class="marginalized" href="#6">6</a></div>
    <div class="itemdescr"><div class="texpara"><div id="6.sentence-1" class="sentence">
        <i>Effects</i>: Equivalent to:
    <span class="codeblock"><span class="keyword">if</span> (*<span class="keyword">this</span>) <span class="curlybracket">{</span>
  <span class="keyword">return</span> invoke(std::forward&lt;F&gt;(f), std::move(<del>value()</del><ins>**<span class="keyword">this</span></ins>));
<span class="curlybracket">}</span> <span class="keyword">else</span> <span class="curlybracket">{</span>
  <span class="keyword">return</span> remove_cvref_t&lt;U&gt;();
<span class="curlybracket">}</span>
</span>
    </div></div></div>
</div>

<code class="itemdeclcode">
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> transform(F&amp;&amp; f) &amp;;
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> transform(F&amp;&amp; f) <span class="keyword">const</span> &amp;;
</code>

<div class="para" id="7">
    <div class="marginalizedparent"><a class="marginalized" href="#7">7</a></div>
    <div class="itemdescr"><div class="texpara"><div id="7.sentence-1" class="sentence">
        Let <span class="texttt">U</span> be <span class="texttt">remove_cv_t&lt;invoke_result_t&lt;F, <span class="keyword">decltype</span>(<del>value()</del><ins>**<span class="keyword">this</span></ins>)&gt;&gt;</span>.
    </div></div></div>
</div>

<div class="para" id="8">
    <div class="marginalizedparent"><a class="marginalized" href="#8">8</a></div>
    <div class="itemdescr"><div class="texpara">
        <div id="8.sentence-1" class="sentence">
            <i>Mandates</i>: <span class="texttt">U</span> is a non-array object type other than <span class="texttt">in_place_t</span> or <span class="texttt">nullopt_t</span>.
        </div>
        <div id="8.sentence-2" class="sentence">
            The declaration
<span class="codeblock">U u(invoke(std::forward&lt;F&gt;(f), <del>value()</del><ins>**<span class="keyword">this</span></ins>));
</span>
is well-formed for some invented variable <span class="texttt">u</span>.
        </div>
        <div id="note-1" class="note"><div class="texpara">
            [<i>Note&nbsp;<a href="#note-1">1</a></i>: <div id="8.sentence-3" class="sentence">There is no requirement that <span class="texttt">U</span> is movable (<a href="https://eel.is/c++draft/dcl.init.general">[dcl.init.general]</a>).</div> —&nbsp;<i>end note</i>]
        </div></div>
    </div></div>
</div>

<div class="para" id="9">
    <div class="marginalizedparent"><a class="marginalized" href="#9">9</a></div>
    <div class="itemdescr"><div class="texpara">
        <div id="9.sentence-1" class="sentence">
            <i>Returns</i>: If <span class="texttt">*<span class="keyword">this</span></span> contains a value, an <span class="texttt">optional&lt;U&gt;</span> object
whose contained value is direct-non-list-initialized with
<span class="texttt">invoke(std::forward&lt;F&gt;(f), <del>value()</del><ins>**<span class="keyword">this</span></ins>)</span>;
otherwise, <span class="texttt">optional&lt;U&gt;()</span>.
        </div>
    </div></div>
</div>

<code class="itemdeclcode">
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> transform(F&amp;&amp; f) &amp;&amp;;
<span class="keyword">template</span>&lt;<span class="keyword">class</span> F&gt; <span class="keyword">constexpr</span> <span class="keyword">auto</span> transform(F&amp;&amp; f) <span class="keyword">const</span> &amp;&amp;;
</code>

<div class="para" id="10">
    <div class="marginalizedparent"><a class="marginalized" href="#10">10</a></div>
    <div class="itemdescr"><div class="texpara"><div id="10.sentence-1" class="sentence">
        Let <span class="texttt">U</span> be
<span class="texttt">remove_cv_t&lt;invoke_result_t&lt;F, <span class="keyword">decltype</span>(std::move(<del>value()</del><ins>**<span class="keyword">this</span></ins>))&gt;&gt;</span>.
    </div></div></div>
</div>

<div class="para" id="11">
    <div class="marginalizedparent"><a class="marginalized" href="#11">11</a></div>
    <div class="itemdescr"><div class="texpara">
        <div id="11.sentence-1" class="sentence">
            <i>Mandates</i>: <span class="texttt">U</span> is a non-array object type other than <span class="texttt">in_place_t</span> or <span class="texttt">nullopt_t</span>.
        </div>
        <div id="11.sentence-2" class="sentence">
            The declaration
<span class="codeblock">U u(invoke(std::forward&lt;F&gt;(f), std::move(<del>value()</del><ins>**<span class="keyword">this</span></ins>)));
</span>
is well-formed for some invented variable <span class="texttt">u</span>.
        </div>
        <div id="note-2" class="note"><div class="texpara">
            [<i>Note&nbsp;<a href="#note-2">2</a></i>: <div id="11.sentence-3" class="sentence">There is no requirement that <span class="texttt">U</span> is movable (<a href="https://eel.is/c++draft/dcl.init.general">[dcl.init.general]</a>).</div> —&nbsp;<i>end note</i>]
        </div></div>
    </div></div>
</div>

<div class="para" id="12">
    <div class="marginalizedparent"><a class="marginalized" href="#12">12</a></div>
    <div class="itemdescr"><div class="texpara">
        <div id="12.sentence-1" class="sentence">
            <i>Returns</i>: If <span class="texttt">*<span class="keyword">this</span></span> contains a value, an <span class="texttt">optional&lt;U&gt;</span> object
whose contained value is direct-non-list-initialized with
<span class="texttt">invoke(std::forward&lt;F&gt;(f), std::move(<del>value()</del><ins>**<span class="keyword">this</span></ins>))</span>;
otherwise, <span class="texttt">optional&lt;U&gt;()</span>.
        </div>
    </div></div>
</div>

</blockquote>
</p>

<h2>Changes in <a href="https://eel.is/c++draft/variant.syn">[variant.syn]</a></h2>
Instructions to the editor:<br/>
<p>
Please insert a <code><i>// mostly freestanding</i></code> comment at the beginning of the <a href="https://eel.is/c++draft/variant.syn">[variant.syn]</a> synopsis.<br/>
</p><p>
Please append a <code><i>// freestanding-deleted</i></code> comment to every <code>get</code> overload in the synopsis.
</p>


<h2>Changes in <a href="https://eel.is/c++draft/variant.ctor">[variant.ctor]</a></h2>
<p>

<blockquote class="std">

<div class="texpara"><div id="lib:variant,constructor_"><div class="itemdecl">
<code class="itemdeclcode"><span class="keyword">constexpr</span> variant(<span class="keyword">const</span> variant<span class="operator">&amp;</span> w);
</code></div></div></div>

<div class="para" id="7"><div class="marginalizedparent"><a class="marginalized" href="#7">7</a></div><div class="itemdescr"><div class="texpara"><div id="7.sentence-1" class="sentence"><i>Effects</i>: If <span class="texttt">w</span> holds a value, initializes the <span class="texttt">variant</span> to hold the same
alternative as <span class="texttt">w</span> and direct-initializes the contained value
with <span class="texttt"><del>get&lt;j&gt;(w)</del><ins>*get_if&lt;j&gt;(addressof(w))</ins></span>, where <span class="texttt">j</span> is <span class="texttt">w.index()</span><a class="hidden_link" href="#7.sentence-1">.</a></div> <div id="7.sentence-2" class="sentence">Otherwise, initializes the <span class="texttt">variant</span> to not hold a value<a class="hidden_link" href="#7.sentence-2">.</a></div></div></div></div>

<div class="para" id="8"><div class="marginalizedparent"><a class="marginalized" href="#8">8</a></div><div class="itemdescr"><div class="texpara"><div id="8.sentence-1" class="sentence"><i>Throws</i>: Any exception thrown by direct-initializing any <span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#8.sentence-1">.</a></div></div></div></div>

<div class="para" id="9"><div class="marginalizedparent"><a class="marginalized" href="#9">9</a></div><div class="itemdescr"><div class="texpara"><div id="9.sentence-1" class="sentence"><i>Remarks</i>: This constructor is defined as deleted unless
<span class="texttt">is_copy_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span> is <span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#9.sentence-1">.</a></div> <div id="9.sentence-2" class="sentence">If <span class="texttt">is_trivially_copy_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span>
is <span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span>, this constructor is trivial<a class="hidden_link" href="#9.sentence-2">.</a></div></div></div></div>

<div class="texpara"><div id="lib:variant,constructor__"><div class="itemdecl"><code class="itemdeclcode"><span class="keyword">constexpr</span> variant(variant<span class="operator">&amp;</span><span class="operator">&amp;</span> w) <span class="keyword">noexcept</span>(<i><span class="texttt">see below</span></i>);
</code></div></div></div>

<div class="para" id="10"><div class="marginalizedparent"><a class="marginalized" href="#10">10</a></div><div class="itemdescr"><div class="texpara"><div id="10.sentence-1" class="sentence"><i>Constraints</i>: <span class="texttt">is_move_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span> is <span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#10.sentence-1">.</a></div></div></div></div>

<div class="para" id="11"><div class="marginalizedparent"><a class="marginalized" href="#11">11</a></div><div class="itemdescr"><div class="texpara"><div id="11.sentence-1" class="sentence"><i>Effects</i>: If <span class="texttt">w</span> holds a value, initializes the <span class="texttt">variant</span> to hold the same
alternative as <span class="texttt">w</span> and direct-initializes the contained value with
<span class="texttt"><del>get&lt;j&gt;(std::move(w))</del><ins>std::move(*get_if&lt;j&gt;(addressof(w)))</ins></span>, where <span class="texttt">j</span> is <span class="texttt">w.index()</span><a class="hidden_link" href="#11.sentence-1">.</a></div> <div id="11.sentence-2" class="sentence">Otherwise, initializes the <span class="texttt">variant</span> to not hold a value<a class="hidden_link" href="#11.sentence-2">.</a></div></div></div></div>


</blockquote>
</p>



<h2>Changes in <a href="https://eel.is/c++draft/variant.assign">[variant.assign]</a></h2>
<p>

<blockquote class="std">

<div class="texpara"><div id="lib:variant,operator="><div id="lib:operator=,variant"><div class="itemdecl"><code class="itemdeclcode"><span class="keyword">constexpr</span> variant<span class="operator">&amp;</span> <span class="keyword">operator</span>=(<span class="keyword">const</span> variant<span class="operator">&amp;</span> rhs);
</code></div></div></div></div>
<div class="para" id="1"><div class="marginalizedparent"><a class="marginalized" href="#1">1</a></div><div class="itemdescr"><div class="texpara"><div id="1.sentence-1" class="sentence">Let <span class="math"><span class="mathalpha">j</span></span> be <span class="texttt">rhs.index()</span><a class="hidden_link" href="#1.sentence-1">.</a></div></div></div></div>

<div class="para" id="2"><div class="marginalizedparent"><a class="marginalized" href="#2">2</a></div><div class="itemdescr"><div class="texpara"><div id="2.sentence-1" class="sentence"><i>Effects</i>: 
    <ul class="itemize">
        <li id="2.1"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#2.1">(2.1)</a></div><div class="texpara"><div id="2.1.sentence-1" class="sentence">If neither <span class="texttt">*<span class="keyword">this</span></span> nor <span class="texttt">rhs</span> holds a value, there is no effect<a class="hidden_link" href="#2.1.sentence-1">.</a></div></div></li>
        <li id="2.2"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#2.2">(2.2)</a></div><div class="texpara"><div id="2.2.sentence-1" class="sentence">Otherwise, if <span class="texttt">*<span class="keyword">this</span></span> holds a value but <span class="texttt">rhs</span> does not, destroys the value
contained in <span class="texttt">*<span class="keyword">this</span></span> and sets <span class="texttt">*<span class="keyword">this</span></span> to not hold a value<a class="hidden_link" href="#2.2.sentence-1">.</a></div></div></li>
        <li id="2.3"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#2.3">(2.3)</a></div><div class="texpara"><div id="2.3.sentence-1" class="sentence">Otherwise, if <span class="texttt">index() == <span class="math"><span class="mathalpha">j</span></span></span>, assigns the value contained in <span class="texttt">rhs</span>
to the value contained in <span class="texttt">*<span class="keyword">this</span></span><a class="hidden_link" href="#2.3.sentence-1">.</a></div></div></li>
        <li id="2.4"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#2.4">(2.4)</a></div><div class="texpara"><div id="2.4.sentence-1" class="sentence">Otherwise, if either <span class="texttt">is_nothrow_copy_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.519em;">j</span></span></span></span></span></span></span>&gt;</span>
is <span class="texttt"><span class="literal">true</span></span> or
<span class="texttt">is_nothrow_move_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.519em;">j</span></span></span></span></span></span></span>&gt;</span> is <span class="texttt"><span class="literal">false</span></span>,
equivalent to <span class="texttt">emplace&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(<del>get&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(rhs)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(addressof(rhs))</ins>)</span><a class="hidden_link" href="#2.4.sentence-1">.</a></div></div></li>
        <li id="2.5"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#2.5">(2.5)</a></div><div class="texpara"><div id="2.5.sentence-1" class="sentence">Otherwise, equivalent to <span class="texttt"><span class="keyword">operator</span>=(variant(rhs))</span><a class="hidden_link" href="#2.5.sentence-1">.</a></div></div></li>
    </ul></div></div></div></div>
    
<div class="para" id="3"><div class="marginalizedparent"><a class="marginalized" href="#3">3</a></div><div class="itemdescr"><div class="texpara"><div id="3.sentence-1" class="sentence"><i>Postconditions</i>: <span class="texttt">index() == rhs.index()</span><a class="hidden_link" href="#3.sentence-1">.</a></div></div></div></div>

<div class="para" id="4"><div class="marginalizedparent"><a class="marginalized" href="#4">4</a></div><div class="itemdescr"><div class="texpara"><div id="4.sentence-1" class="sentence"><i>Returns</i>: <span class="texttt">*<span class="keyword">this</span></span><a class="hidden_link" href="#4.sentence-1">.</a></div></div></div></div>

<div class="para" id="5"><div class="marginalizedparent"><a class="marginalized" href="#5">5</a></div><div class="itemdescr"><div class="texpara"><div id="5.sentence-1" class="sentence"><i>Remarks</i>: This operator is defined as deleted unless
<span class="texttt">is_copy_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt; <span class="operator">&amp;</span><span class="operator">&amp;</span></span>
<span class="texttt">is_copy_assignable_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span>
is <span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#5.sentence-1">.</a></div> <div id="5.sentence-2" class="sentence">If <span class="texttt">is_trivially_copy_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt; <span class="operator">&amp;</span><span class="operator">&amp;</span></span>
<span class="texttt">is_trivially_copy_assignable_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt; <span class="operator">&amp;</span><span class="operator">&amp;</span></span>
<span class="texttt">is_trivially_destructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span>
is <span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span>, this assignment operator is trivial<a class="hidden_link" href="#5.sentence-2">.</a></div></div></div></div><div class="texpara"><div id="lib:variant,operator=_"><div id="lib:operator=,variant_"><div class="itemdecl"><div class="marginalizedparent"><a class="itemDeclLink" href="#lib:operator=,variant_">🔗</a></div><code class="itemdeclcode"><span class="keyword">constexpr</span> variant<span class="operator">&amp;</span> <span class="keyword">operator</span>=(variant<span class="operator">&amp;</span><span class="operator">&amp;</span> rhs) <span class="keyword">noexcept</span>(<i><span class="texttt">see below</span></i>);
</code></div></div></div></div>

<div class="para" id="6"><div class="marginalizedparent"><a class="marginalized" href="#6">6</a></div><div class="itemdescr"><div class="texpara"><div id="6.sentence-1" class="sentence">Let <span class="math"><span class="mathalpha">j</span></span> be <span class="texttt">rhs.index()</span><a class="hidden_link" href="#6.sentence-1">.</a></div></div></div></div>

<div class="para" id="7"><div class="marginalizedparent"><a class="marginalized" href="#7">7</a></div><div class="itemdescr"><div class="texpara"><div id="7.sentence-1" class="sentence"><i>Constraints</i>: <span class="texttt">is_move_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt; <span class="operator">&amp;</span><span class="operator">&amp;</span></span>
<span class="texttt">is_move_assignable_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span> is
<span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#7.sentence-1">.</a></div></div></div></div>

<div class="para" id="8"><div class="marginalizedparent"><a class="marginalized" href="#8">8</a></div><div class="itemdescr"><div class="texpara"><div id="8.sentence-1" class="sentence"><i>Effects</i>: 
    <ul class="itemize">
        <li id="8.1"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#8.1">(8.1)</a></div><div class="texpara"><div id="8.1.sentence-1" class="sentence">If neither <span class="texttt">*<span class="keyword">this</span></span> nor <span class="texttt">rhs</span> holds a value, there is no effect<a class="hidden_link" href="#8.1.sentence-1">.</a></div></div></li>
        <li id="8.2"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#8.2">(8.2)</a></div><div class="texpara"><div id="8.2.sentence-1" class="sentence">Otherwise, if <span class="texttt">*<span class="keyword">this</span></span> holds a value but <span class="texttt">rhs</span> does not, destroys the value
contained in <span class="texttt">*<span class="keyword">this</span></span> and sets <span class="texttt">*<span class="keyword">this</span></span> to not hold a value<a class="hidden_link" href="#8.2.sentence-1">.</a></div></div></li>
        <li id="8.3"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#8.3">(8.3)</a></div><div class="texpara"><div id="8.3.sentence-1" class="sentence">Otherwise, if <span class="texttt">index() == <span class="math"><span class="mathalpha">j</span></span></span>, 
assigns <span class="texttt"><del>get&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(std::move(rhs))</del><ins>std::move(*get_if&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(addressof(rhs)))</ins></span> to

the value contained in <span class="texttt">*<span class="keyword">this</span></span><a class="hidden_link" href="#8.3.sentence-1">.</a></div></div></li>
        <li id="8.4"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#8.4">(8.4)</a></div><div class="texpara"><div id="8.4.sentence-1" class="sentence">Otherwise,
equivalent to <span class="texttt">emplace&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(<del>get&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(std::move(rhs))</del><ins>std::move(*get_if&lt;<span class="math"><span class="mathalpha">j</span></span>&gt;(addressof(rhs)))</ins>)</span><a class="hidden_link" href="#8.4.sentence-1">.</a></div></div></li>

    </ul></div></div></div>
</div>

</blockquote>
</p>








<h2>Changes in <a href="https://eel.is/c++draft/variant.swap">[variant.swap]</a></h2>
<p>

<blockquote class="std">


<div class="texpara"><div id="lib:variant,swap"><div id="lib:swap,variant"><div class="itemdecl"><div class="marginalizedparent"><a class="itemDeclLink" href="#lib:swap,variant">🔗</a></div><code class="itemdeclcode"><span class="keyword">constexpr</span> <span class="keyword">void</span> swap(variant<span class="operator">&amp;</span> rhs) <span class="keyword">noexcept</span>(<i><span class="texttt">see below</span></i>);
</code></div></div></div></div>
<div class="para" id="swap-1"><div class="marginalizedparent"><a class="marginalized" href="#swap-1">1</a></div><div class="itemdescr"><div class="texpara"><div id="swap-1.sentence-1" class="sentence"><i>Mandates</i>: <span class="texttt">is_move_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span> is <span class="texttt"><span class="literal">true</span></span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#swap-1.sentence-1">.</a></div></div></div></div>
<div class="para" id="swap-2"><div class="marginalizedparent"><a class="marginalized" href="#swap-2">2</a></div><div class="itemdescr"><div class="texpara"><div id="swap-2.sentence-1" class="sentence"><i>Preconditions</i>: Each <span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span> meets the <i>Cpp17Swappable</i> requirements (<a href="https://eel.is/c++draft/swappable.requirements">[swappable.requirements]</a>)<a class="hidden_link" href="#swap-2.sentence-1">.</a></div></div></div></div>
<div class="para" id="swap-3"><div class="marginalizedparent"><a class="marginalized" href="#swap-3">3</a></div><div class="itemdescr"><div class="texpara"><div id="swap-3.sentence-1" class="sentence"><i>Effects</i>: 
    <ul class="itemize">
        <li id="swap-3.1"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#swap-3.1">(3.1)</a></div><div class="texpara"><div id="swap-3.1.sentence-1" class="sentence">If <span class="texttt">valueless_by_exception() <span class="operator">&amp;</span><span class="operator">&amp;</span> rhs.valueless_by_exception()</span> no effect<a class="hidden_link" href="#swap-3.1.sentence-1">.</a></div></div></li>
        <li id="swap-3.2"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#swap-3.2">(3.2)</a></div><div class="texpara"><div id="swap-3.2.sentence-1" class="sentence">
            Otherwise, if <span class="texttt">index() == rhs.index()</span>, calls 
            <span class="texttt">swap(<del>get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(*<span class="keyword">this</span>)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(<span class="keyword">this</span>)</ins>, <del>get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(rhs)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(addressof(rhs))</ins>)</span>
            where <span class="math"><span class="mathalpha">i</span></span> is <span class="texttt">index()</span><a class="hidden_link" href="#swap-3.2.sentence-1">.</a></div></div></li>
        <li id="swap-3.3"><div class="marginalizedparent" style="left:-39mm"><a class="marginalized" href="#swap-3.3">(3.3)</a></div><div class="texpara"><div id="swap-3.3.sentence-1" class="sentence">Otherwise, exchanges values of <span class="texttt">rhs</span> and <span class="texttt">*<span class="keyword">this</span></span><a class="hidden_link" href="#swap-3.3.sentence-1">.</a></div></div></li>
    </ul>
</div></div></div></div>

<div class="para" id="swap-4"><div class="marginalizedparent"><a class="marginalized" href="#swap-4">4</a></div><div class="itemdescr"><div class="texpara"><div id="swap-4.sentence-1" class="sentence"><i>Throws</i>: If <span class="texttt">index() == rhs.index()</span>,
any exception thrown by

<span class="texttt">swap(<del>get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(*<span class="keyword">this</span>)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(<span class="keyword">this</span>)</ins>, <del>get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(rhs)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(addressof(rhs))</ins>)</span>

with <span class="math"><span class="mathalpha">i</span></span> being <span class="texttt">index()</span><a class="hidden_link" href="#swap-4.sentence-1">.</a></div> <div id="swap-4.sentence-2" class="sentence">Otherwise, any exception thrown by the move constructor
of <span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span> or <span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.519em;">j</span></span></span></span></span></span></span>
with <span class="math"><span class="mathalpha">i</span></span> being <span class="texttt">index()</span> and <span class="math"><span class="mathalpha">j</span></span> being <span class="texttt">rhs.index()</span><a class="hidden_link" href="#swap-4.sentence-2">.</a></div></div></div></div>

<div class="para" id="swap-5"><div class="marginalizedparent"><a class="marginalized" href="#swap-5">5</a></div><div class="itemdescr"><div class="texpara"><div id="swap-5.sentence-1" class="sentence"><i>Remarks</i>: If an exception is thrown during the call to function 

<span class="texttt">swap(<del>get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(*<span class="keyword">this</span>)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(<span class="keyword">this</span>)</ins>, <del>get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(rhs)</del><ins>*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(addressof(rhs))</ins>)</span>,

the states of the contained values of <span class="texttt">*<span class="keyword">this</span></span> and of <span class="texttt">rhs</span> are
determined by the exception safety guarantee of <span class="texttt">swap</span> for lvalues of
<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span> with <span class="math"><span class="mathalpha">i</span></span> being <span class="texttt">index()</span><a class="hidden_link" href="#swap-5.sentence-1">.</a></div> <div id="swap-5.sentence-2" class="sentence">If an exception is thrown during the exchange of the values of <span class="texttt">*<span class="keyword">this</span></span>
and <span class="texttt">rhs</span>, the states of the values of <span class="texttt">*<span class="keyword">this</span></span> and of <span class="texttt">rhs</span>
are determined by the exception safety guarantee of <span class="texttt">variant</span>'s move constructor<a class="hidden_link" href="#swap-5.sentence-2">.</a></div> <div id="swap-5.sentence-3" class="sentence">The exception specification is equivalent to the logical <span class="textsc">and</span> of
<span class="texttt">is_nothrow_move_constructible_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt; <span class="operator">&amp;</span><span class="operator">&amp;</span> is_nothrow_swappable_v&lt;<span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">T</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span></span></span></span>&gt;</span> for all <span class="math"><span class="mathalpha">i</span></span><a class="hidden_link" href="#swap-5.sentence-3">.</a></div></div></div></div></div></div>

</blockquote>
</p>

<h2>Changes in <a href="https://eel.is/c++draft/variant.relops">[variant.relops]</a></h2>

Instructions to the editor:<br/>
<p>
Replace every instance of
<span class="texttt">get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(v)</span>
in <a href="https://eel.is/c++draft/variant.relops">[variant.relops]</a> with
<ins><span class="texttt">*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(addressof(v))</span></ins>.
</p><p>
Replace every instance of
<span class="texttt">get&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(w)</span>
in <a href="https://eel.is/c++draft/variant.relops">[variant.relops]</a> with
<ins><span class="texttt">*get_if&lt;<span class="math"><span class="mathalpha">i</span></span>&gt;(addressof(w))</span></ins>.

</p>

<h2>Changes in <a href="https://eel.is/c++draft/variant.visit">[variant.visit]</a></h2>
<p>
<blockquote class="std">

<div class="para" id="4">
    <div class="marginalizedparent"><a class="marginalized" href="#4">4</a></div>
    <div class="itemdescr"><div class="texpara"><div id="4.sentence-1" class="sentence">Let <span class="math"><span class="mathalpha">m</span></span> be a pack of <span class="math"><span class="mathalpha">n</span></span> values of type <span class="texttt">size_<span class="shy"></span>t</span><a class="hidden_link" href="#4.sentence-1">.</a></div> <div id="4.sentence-2" class="sentence">Such a pack is valid if<br><span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-mn"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.372em;">0</span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.446em;">≤</span></span><span class="mjx-texatom MJXc-space3"><span class="mjx-mrow"></span></span><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">m</span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.225em; padding-bottom: 0.372em;">&lt;</span></span><span class="mjx-msubsup MJXc-space3"><span class="mjx-base"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.446em; padding-bottom: 0.372em;">variant_size_v&lt;remove_reference_t&lt;V</span></span></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.22em; padding-right: 0.071em;"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span></span></span><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mtext"><span class="mjx-char MJXc-TeX-type-R" style="padding-top: 0.372em; padding-bottom: 0.225em;">&gt;&gt;</span></span></span></span></span></span></span>
for all <span class="mjx-chtml"><span class="mjx-math"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-mn"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.372em;">0</span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.372em; padding-bottom: 0.446em;">≤</span></span><span class="mjx-texatom MJXc-space3"><span class="mjx-mrow"></span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.446em; padding-bottom: 0.298em;">i</span></span><span class="mjx-mo MJXc-space3"><span class="mjx-char MJXc-TeX-main-R" style="padding-top: 0.225em; padding-bottom: 0.372em;">&lt;</span></span><span class="mjx-mi MJXc-space3"><span class="mjx-char MJXc-TeX-math-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">n</span></span></span></span></span><a class="hidden_link" href="#4.sentence-2">.</a></div> <div id="4.sentence-3" class="sentence">For each valid pack <span class="math"><span class="mathalpha">m</span></span>, let <span class="math"><span class="mathalpha">e</span>(<span class="mathalpha">m</span>)</span> denote the expression:

<del><span class="codeblock"><i>INVOKE</i>(std::forward&lt;Visitor&gt;(vis), get&lt;<span class="math"><span class="mathalpha">m</span></span>&gt;(std::forward&lt;V&gt;(vars))...)  <span class="comment">// see <a href="https://eel.is/c++draft/func.require">[func.require]</a></span>
</span></del>
<ins><span class="codeblock"><i>INVOKE</i>(std::forward&lt;Visitor&gt;(vis), forward_like&lt;V&gt;(*get_if&lt;<span class="math"><span class="mathalpha">m</span></span>&gt;(addressof(vars)))...)  <span class="comment">// see <a href="https://eel.is/c++draft/func.require">[func.require]</a></span>
</span></ins>
for the first form and

<del><span class="codeblock"><i>INVOKE</i>&lt;R&gt;(std::forward&lt;Visitor&gt;(vis), get&lt;<span class="math"><span class="mathalpha">m</span></span>&gt;(std::forward&lt;V&gt;(vars))...)  <span class="comment">// see <a href="https://eel.is/c++draft/func.require">[func.require]</a></span>
</span></del>
<ins><span class="codeblock"><i>INVOKE</i>&lt;R&gt;(std::forward&lt;Visitor&gt;(vis), forward_like&lt;V&gt;(*get_if&lt;<span class="math"><span class="mathalpha">m</span></span>&gt;(addressof(vars)))...)  <span class="comment">// see <a href="https://eel.is/c++draft/func.require">[func.require]</a></span>
</span></ins>
for the second form.</div></div></div></div>


</blockquote>
</p>


<h2>Changes in <a href="https://eel.is/c++draft/string.view.synop">[string.view.synop]</a></h2>
Instructions to the editor:<br/>
<p>
Please insert a <code><i>// mostly freestanding</i></code> comment at the beginning of the <a href="https://eel.is/c++draft/string.view.synop">[string.view.synop]</a> synopsis.<br/>
</p>
Please append a <code><i>// hosted</i></code> comment to the following declaration:
<ul>
  <li><code>operator&lt;&lt;</code></li>
</ul>
Please append a <code><i>// freestanding-partial</i></code> comment to the following declaration:
<ul>
  <li><code>basic_string_view</code></li>
</ul>

<h2>Changes in <a href="https://eel.is/c++draft/string.view.template.general">[string.view.template.general]</a></h2>
Instructions to the editor:<br/>
Please append a <code><i>// freestanding-deleted</i></code> to the following functions:
<ul>
  <li><code>at</code></li>
  <li><code>copy</code></li>
  <li><code>substr</code></li>
  <li>The following overloads of compare:<ul>
      <li><code>compare(size_type pos1, size_type n1, basic_string_view s)</code></li>
      <li><code>compare(size_type pos1, size_type n1, basic_string_view s, size_type pos2, size_type n2)</code></li>
      <li><code>compare(size_type pos1, size_type n1, const charT* s)</code></li>
      <li><code>compare(size_type pos1, size_type n1, const charT* s, size_type n2)</code></li>
  </ul></li>
</ul>
<p>
Note that the <code>compare(basic_string_view str) const</code> and <code>compare(const charT* s) const</code> overloads are intentionally not freestanding-deleted.
</p>

<h2>Changes in <a href="https://eel.is/c++draft/string.view.ops">[string.view.ops]</a></h2>

Please modify the <a href="https://eel.is/c++draft/string.view.ops#20"><code>basic_string_view</code> overload of <code>starts_with</code></a> so that it doesn't reference <i>freestanding-deleted</i> methods.
<blockquote class="std">
<code>constexpr bool starts_with(basic_string_view x) const noexcept;</code>
<div class="para">
    <ins>
        <div class='marginalizedparent'><a class='marginalized'>?</a></div>
        <div class="sentence">Let <code>rlen</code> be the smaller of <code>size()</code> and <code>x.size()</code>.</div>
    </ins>
    <div class='marginalizedparent'><a class='marginalized'>?</a></div>
    <div class="sentence"><i>Effects</i>: Equivalent to: 
        <del><code>return substr(0, x.size()) == x;</code></del>
        <ins><code>return basic_string_view(data(), rlen) == x;</code></ins>
    </div>
</div>
</blockquote>

Please modify the <a href="https://eel.is/c++draft/string.view.ops#23"><code>basic_string_view</code> overload of <code>ends_with</code></a> so that it doesn't reference <i>freestanding-deleted</i> methods.

<blockquote class="std">
<code>constexpr bool ends_with(basic_string_view x) const noexcept;</code>
<div class="para">
    <ins>
        <div class='marginalizedparent'><a class='marginalized'>?</a></div>
        <div class="sentence">Let <code>rlen</code> be the smaller of <code>size()</code> and <code>x.size()</code>.</div>
    </ins>
    <div class='marginalizedparent'><a class='marginalized'>?</a></div>
    <div class="sentence"><i>Effects</i>: Equivalent to: 
        <del><code>return size() &gt;= x.size() && compare(size() - x.size(), npos, x) == 0</code></del>
        <ins><code>return basic_string_view(data() + (size() - rlen), rlen) == x;</code></ins>
    </div>
</div>
</blockquote>

<h2>Changes in <a href="https://eel.is/c++draft/string.view.find">[string.view.find]</a></h2>

Instructions to the editor:<br/>
<p>
    Replace every instance of
    <span class="texttt">at(xpos + I)</span>
    in <a href="https://eel.is/c++draft/string.view.find">[string.view.find]</a> with
    <ins><span class="texttt">data_[xpos + I]</span></ins>.
</p><p>
    Replace every instance of
    <span class="texttt">at(xpos)</span>
    in <a href="https://eel.is/c++draft/string.view.find">[string.view.find]</a> with
    <ins><span class="texttt">data_[xpos]</span></ins>.
</p><p>
    Replace every instance of
    <span class="texttt">str.at(I)</span>
    in <a href="https://eel.is/c++draft/string.view.find">[string.view.find]</a> with
    <ins><span class="texttt">str.data_[I]</span></ins>.
</p>

<h2>Changes in <a href="https://eel.is/c++draft/array.syn">[array.syn]</a></h2>
Instructions to the editor:<br/>
<p>
Please insert a <code><i>// mostly freestanding</i></code> comment at the beginning of the <a href="https://eel.is/c++draft/array.syn">[array.syn]</a> synopsis.<br/>
</p><p>
Please append a <code><i>// freestanding-partial</i></code> comment to <code>array</code><br/>
</p>

<h2>Changes in <a href="https://eel.is/c++draft/array.overview">[array.overview]</a></h2>
Instructions to the editor:<br/>
Please append a <code><i>// freestanding-deleted</i></code> comment to every overload of <code>at</code>.

<h2>Changes in <a href="https://eel.is/c++draft/algorithm.syn">[algorithm.syn]</a></h2>
Instructions to the editor:<br/>
<p>
Please append a <code><i>// freestanding</i></code> comment to the following functions:
<ul>
    <li><code>fill_n(OutputIterator first, Size n, const T& value)</code></li>
    <li><code>swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2)</code></li>
</ul>
</p>

<h1>References</h1>
[AK] Andreas Kling. Serenity OS AK Library.<br/>
&emsp;&emsp;https://github.com/SerenityOS/serenity/tree/master/AK<br/>
[Embedded Template Library] John Wellbelove. Embedded Template Library.<br/>
&emsp;&emsp;https://www.etlcpp.com/<br/>
[N4928] Thomas Köppe. 2022-12-18. Working Draft, Standard for Programming Language C++.<br/>
&emsp;&emsp;https://wg21.link/n4928<br/>
[P2198R6] Ben Craig. 2022-12-06. Freestanding Feature-Test Macros and Implementation-Defined Extensions.<br/>
&emsp;&emsp;https://wg21.link/P2198R6<br/>
[P2268R0] Ben Craig. 2020-12-10. Freestanding Roadmap.<br/>
&emsp;&emsp;https://wg21.link/p2268r0<br/>
[P2338R4] Ben Craig. 2023-02-09. Freestanding Library: Character primitives and the C library.<br/>
&emsp;&emsp;https://wg21.link/P2338R4<br/>

</body>
</html>
