<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3631: basic_format_arg(T&amp;&amp;) should use remove_cvref_t&lt;T&gt; throughout</title>
<meta property="og:title" content="Issue 3631: basic_format_arg(T&amp;&amp;) should use remove_cvref_t&lt;T&gt; throughout">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3631.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++23">C++23</a> status.</em></p>
<h3 id="3631"><a href="lwg-defects.html#3631">3631</a>. <code>basic_format_arg(T&amp;&amp;)</code> should use <code>remove_cvref_t&lt;T&gt;</code> throughout</h3>
<p><b>Section:</b> 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2021-11-03 <b>Last modified:</b> 2023-11-22</p>
<p><b>Priority: </b>3
</p>
<p><b>View all other</b> <a href="lwg-index.html#format.arg">issues</a> in [format.arg].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++23">C++23</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<a href="https://wg21.link/P2418R2" title=" Add support for std::generator-like types to std::format">P2418R2</a> changed <code>basic_format_arg</code>'s constructor to take a forwarding
reference but didn't change 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a>/5 which inspects various
properties of <code>T</code>. Now that the deduced type can be <i>cvref</i>-qualified,
they need to be removed before the checks.
</p>

<p><i>[2022-01-29; Reflector poll]</i></p>

<p>
Set priority to 3 after reflector poll.
</p>
<p>
Two suggestions to just change it to be <code>T&amp;</code> because we don't
need forwarding references here, and only accepting lvalues prevents
forming dangling references.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/N4901" title=" Working Draft, Standard for Programming Language C++">N4901</a>.
</p>

<ol>
<li><p>Modify 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;class T&gt; explicit basic_format_arg(T&amp;&amp; v) noexcept;
</pre>
<blockquote>
<p>
<ins>-?- Let <code>TD</code> be <code>remove_cvref_t&lt;T&gt;</code>.</ins>
<p/>
-4- <i>Constraints:</i> The template specialization
</p>
<blockquote><pre>
typename Context::template formatter_type&lt;<del>remove_cvref_t&lt;T&gt;</del><ins>TD</ins>&gt;
</pre></blockquote>
<p>
meets the <i>BasicFormatter</i> requirements (28.5.6.1 <a href="https://wg21.link/formatter.requirements">[formatter.requirements]</a>). The extent to
which an implementation determines that the specialization meets the <i>BasicFormatter</i>
requirements is unspecified, except that as a minimum the expression
</p>
<blockquote><pre>
typename Context::template formatter_type&lt;<del>remove_cvref_t&lt;T&gt;</del><ins>TD</ins>&gt;()
  .format(declval&lt;T&amp;&gt;(), declval&lt;Context&amp;&gt;())
</pre></blockquote>
<p>
shall be well-formed when treated as an unevaluated operand (7.2.3 <a href="https://wg21.link/expr.context">[expr.context]</a>).
<p/>
-5- <i>Effects:</i>
</p>
<ol style="list-style-type:none">
<li><p>(5.1) &mdash; if <code>T<ins>D</ins></code> is <code>bool</code> or <code>char_type</code>, initializes <code>value</code> with <code>v</code>;</p></li>
<li><p>(5.2) &mdash; otherwise, if <code>T<ins>D</ins></code> is <code>char</code> and <code>char_type</code> is <code>wchar_t</code>,
initializes <code>value</code> with <code>static_cast&lt;wchar_t&gt;(v)</code>;</p></li>
<li><p>(5.3) &mdash; otherwise, if <code>T<ins>D</ins></code> is a signed integer type (6.9.2 <a href="https://wg21.link/basic.fundamental">[basic.fundamental]</a>) and
<code>sizeof(T<ins>D</ins>) &lt;= sizeof(int)</code>, initializes <code>value</code> with <code>static_cast&lt;int&gt;(v)</code>;</p></li>
<li><p>(5.4) &mdash; otherwise, if <code>T<ins>D</ins></code> is an unsigned integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(unsigned int)</code>,
initializes <code>value</code> with <code>static_cast&lt;unsigned int&gt;(v)</code>;</p></li>
<li><p>(5.5) &mdash; otherwise, if <code>T<ins>D</ins></code> is a signed integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(long long int)</code>,
initializes <code>value</code> with <code>static_cast&lt;long long int&gt;(v)</code>;</p></li>
<li><p>(5.6) &mdash; otherwise, if <code>T<ins>D</ins></code> is an unsigned integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(unsigned long long int)</code>, initializes <code>value</code> with <code>static_cast&lt;unsigned long long int&gt;(v)</code>;</p></li>
<li><p>(5.7) &mdash; otherwise, initializes <code>value</code> with <code>handle(v)</code>.</p></li>
</ol>
</blockquote>
</blockquote>
</li>

</ol>
</blockquote>

<p><i>[2022-10-19; Jonathan provides improved wording]</i></p>

<p>
During reflector prioritization it was pointed out that forwarding references
are unnecessary (arguments are always lvalues), and so using <code>T&amp;</code>
would be simpler.
</p>
<p>
In order to resolve the overload ambiguities discussed in <a href="lwg-defects.html#3718" title="P2418R2 broke the overload resolution for std::basic_format_arg (Status: Resolved)">3718</a><sup><a href="https://cplusplus.github.io/LWG/issue3718" title="Latest snapshot">(i)</a></sup>
replace all unary constructor overloads with a single constructor that works
for any formattable type.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">

<p>
This wording is relative to <a href="https://wg21.link/N4917" title=" Working Draft, Standard for Programming Language C++">N4917</a>.
</p>

<ol>
<li><p>Modify 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;class T&gt; explicit basic_format_arg(T&amp;<del>&amp;</del> v) noexcept;
</pre>
<blockquote>
<p>
-4- <i>Constraints:</i>
<ins><code>T</code> satisfies <code>formattable&lt;char_type&gt;</code>.</ins>
<del>The template specialization</del>
</p>
<blockquote><pre><del>
typename Context::template formatter_type&lt;remove_cvref_t&lt;T&gt;&gt;
</del></pre></blockquote>
<p><del>
meets the <i>BasicFormatter</i> requirements (28.5.6.1 <a href="https://wg21.link/formatter.requirements">[formatter.requirements]</a>). The extent to
which an implementation determines that the specialization meets the <i>BasicFormatter</i>
requirements is unspecified, except that as a minimum the expression
</del></p>
<blockquote><pre><del>
typename Context::template formatter_type&lt;remove_cvref_t&lt;T&gt;&gt;()
  .format(declval&lt;T&amp;&gt;(), declval&lt;Context&amp;&gt;())
</del></pre></blockquote>
<p><del>
shall be well-formed when treated as an unevaluated operand (7.2.3 <a href="https://wg21.link/expr.context">[expr.context]</a>).
</del></p>
<p><ins>-?- <i>Preconditions</i>:
If <code>decay_t&lt;T&gt;</code> is <code>char_type*</code> or <code>const char_type*</code>,
<code>static_cast&lt;const char_type*&gt;(v)</code> points to a NTCTS
(3.36 <a href="https://wg21.link/defns.ntcts">[defns.ntcts]</a>).</ins>
</p>
<p>
-5- <i>Effects:</i>
<ins>Let <code>TD</code> be <code>remove_const_t&lt;T&gt;</code>.</ins>
</p>
<ol style="list-style-type:none">
<li><p>(5.1) &mdash; if <code>T<ins>D</ins></code> is <code>bool</code> or <code>char_type</code>, initializes <code>value</code> with <code>v</code>;</p></li>
<li><p>(5.2) &mdash; otherwise, if <code>T<ins>D</ins></code> is <code>char</code> and <code>char_type</code> is <code>wchar_t</code>,
initializes <code>value</code> with <code>static_cast&lt;wchar_t&gt;(v)</code>;</p></li>
<li><p>(5.3) &mdash; otherwise, if <code>T<ins>D</ins></code> is a signed integer type (6.9.2 <a href="https://wg21.link/basic.fundamental">[basic.fundamental]</a>) and
<code>sizeof(T<ins>D</ins>) &lt;= sizeof(int)</code>, initializes <code>value</code> with <code>static_cast&lt;int&gt;(v)</code>;</p></li>
<li><p>(5.4) &mdash; otherwise, if <code>T<ins>D</ins></code> is an unsigned integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(unsigned int)</code>,
initializes <code>value</code> with <code>static_cast&lt;unsigned int&gt;(v)</code>;</p></li>
<li><p>(5.5) &mdash; otherwise, if <code>T<ins>D</ins></code> is a signed integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(long long int)</code>,
initializes <code>value</code> with <code>static_cast&lt;long long int&gt;(v)</code>;</p></li>
<li><p>(5.6) &mdash; otherwise, if <code>T<ins>D</ins></code> is an unsigned integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(unsigned long long int)</code>, initializes <code>value</code> with <code>static_cast&lt;unsigned long long int&gt;(v)</code>;</p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>TD</code> is a standard floating-point type, initializes <code>value</code> with <code>v</code>;</ins></p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>TD</code> is a specialization of
<code>basic_string_view</code> or <code>basic_string</code> and <code>TD::value_type</code> is <code>char_type</code>, initializes <code>value</code> with <code>basic_string_view&lt;char_type&gt;(v.data(), v.size())</code>;</ins></p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>decay_t&lt;TD&gt;</code> is <code>char_type*</code> or <code>const char_type*</code>, initializes <code>value</code> with <code>static_cast&lt;const char_type*&gt;(v)</code>;</ins></p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>is_void_v&lt;remove_pointer_t&lt;TD&gt;&gt;</code> is <code>true</code> or <code>is_null_pointer_v&lt;TD&gt;</code> is <code>true</code>, initializes <code>value</code> with <code>static_cast&lt;const void*&gt;(v)</code>;</ins></p></li>

<li><p>(5.7) &mdash; otherwise, initializes <code>value</code> with <code>handle(v)</code>.</p></li>
</ol>
<p><ins>-?- [<i>Note</i>: Constructing <code>basic_format_arg</code> from a pointer
to a member is ill-formed unless the user provides an enabled specialization
of <code>formatter</code> for that pointer to member type. &mdash; <i>end note</i>]
</ins></p>
</blockquote>

<pre><del>
explicit basic_format_arg(float n) noexcept;
explicit basic_format_arg(double n) noexcept;
explicit basic_format_arg(long double n) noexcept;
</del></pre>
<blockquote>
<p><del>-6- <i>Effects</i>: Initializes <code>value</code> with <code>n</code>.</del></p>
</blockquote>

<pre><del>
explicit basic_format_arg(const char_type* s) noexcept;
</del></pre>
<blockquote>
<p><del>-7- <i>Preconditions</i>: <code>s</code> points to a NTCTS (3.36 <a href="https://wg21.link/defns.ntcts">[defns.ntcts]</a>).</del></p>
<p><del>-8- <i>Effects</i>: Initializes <code>value</code> with <code>s</code>.</del></p>
</blockquote>

<pre><del>
template&lt;class traits&gt;>
  explicit basic_format_arg(basic_string_view&lt;char_type, traits&gt; s) noexcept;
</del></pre>
<blockquote>
<p><del>-9- <i>Effects</i>: Initializes <code>value</code> with <code>basic_string_view&lt;char_type&gt;(s.data(), s.size())</code>.</del></p>
</blockquote>

<pre><del>
template&lt;class traits, class Allocator&gt;>
  explicit basic_format_arg(
    const basic_string&lt;char_type, traits, Allocator&gt;&amp; s) noexcept;
</del></pre>
<blockquote>
<p><del>-10- <i>Effects</i>: Initializes <code>value</code> with <code>basic_string_view&lt;char_type&gt;(s.data(), s.size())</code>.</del></p>
</blockquote>

<pre><del>
explicit basic_format_arg(nullptr_t) noexcept;
</del></pre>
<blockquote>
<p><del>-11- <i>Effects</i>: Initializes <code>value</code> with <code>static_cast&lt;const void*&gt;(nullptr)</code>.</del></p>
</blockquote>

<pre><del>
template&lt;class T&gt; explicit basic_format_arg(T* p) noexcept;
</del></pre>
<blockquote>
<p><del>-12- <i>Constraints</i>: <code>is_void_v&lt;T&gt;</code> is <code>true</code>.</del></p>
<p><del>-13- <i>Effects</i>: Initializes <code>value</code> with <code>p</code>.</del></p>
<p><del>-14- <i>[Note</i>: Constructing <code>basic_format_arg</code> from a pointer
to a member is ill-formed unless the user provides an enabled specialization
of <code>formatter</code> for that pointer to member type. &mdash; <i>end note]</i>
</del></p>
</blockquote>

</blockquote>
</li>

<li><p>Modify 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a> p17 and p18 as indicated:</p>

<blockquote>
<pre>
template&lt;class T&gt; explicit handle(T&amp;<del>&amp;</del> v) noexcept;
</pre>
<blockquote>
<p>-17- Let</p>
<ol style="list-style-type:none">
<li><p>&mdash; (17.1)
<code>TD</code> be <code>remove_<del>cvref</del><ins>const</ins>_t&lt;T&gt;</code>,
</p></li>
<li><p><del>&mdash; (17.2)
<code><i>const-formattable</i></code> be <code>true</code> if
<code>typename Context::template formatter_type&lt;TD&gt;().format(declval&lt;const TD&amp;&gt;(), declval&lt;Context&amp;&gt;())</code>
is well-formed, otherwise <code>false</code>,</del>
</p></li>
<li><p>&mdash; (17.3)
<code>TQ</code> be <code>const TD</code> if
<del><code><i>const-formattable</i></code> is <code>true</code></del>
<ins><code>const TD</code> satisfies <code>formattable&lt;char_type&gt;</code></ins>
and <code>TD</code> otherwise.
</p></li>
</ol>
<p>-18- <i>Mandates</i>:
<code><del><i>const-formattable</i></del>
<ins><code>formattable&lt;const TD, char_type&gt;</code></ins>
||
!is_const_v&lt;<del>remove_reference_t&lt;</del>T<del>&gt;</del></code>
is <code>true</code>.
</p>
<p>-19- <i>Effects</i>:
Initializes <code>ptr_</code> with <code>addressof(val)</code> and <code>format_</code> with
<blockquote><pre>
[](basic_format_parse_context&lt;char_type&gt;&amp; parse_ctx,
   Context&amp; format_ctx, const void* ptr) {
  typename Context::template formatter_type&lt;TD&gt; f;
  parse_ctx.advance_to(f.parse(parse_ctx));
  format_ctx.advance_to(f.format(*const_cast&lt;TQ*&gt;(static_cast&lt;const TD*&gt;(ptr)),
                                 format_ctx));
}
</pre></blockquote>
</p>
</blockquote>
</blockquote>
</li>
</ol>

</blockquote>

<p><i>[2022-11-10; Jonathan provides improved wording]</i></p>


<p><i>[2022-11-29; Casey expands the issue to also cover <code>make_format_args</code>]</i></p>


<p><i>[2023-01-11; Jonathan adds the missing edits to the class synopsis]</i></p>


<p><i>[Issaquah 2023-02-07; LWG]</i></p>

<p>
Edited proposed resolution to
remove extra <ins><code>=</code></ins> in concept definition
and capitialize start of (5.1).
Move to Immediate for C++23
</p>

<p><i>[2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Immediate &rarr; WP.]</i></p>



<p id="res-3631"><b>Proposed resolution:</b></p>

<p>
This wording is relative to <a href="https://wg21.link/N4917" title=" Working Draft, Standard for Programming Language C++">N4917</a>.
</p>

<ol>
<li><p>Modify 28.5.6.3 <a href="https://wg21.link/format.formattable">[format.formattable]</a> as indicated:</p>

<p>
-1- Let <code><i>fmt-iter-for</i>&lt;charT&gt;</code> be an unspecified type that models
<code>output_iterator&lt;const charT&amp;&gt;</code> (24.3.4.10 <a href="https://wg21.link/iterator.concept.output">[iterator.concept.output]</a>).
</p>

<blockquote><pre><ins>
  template&lt;class T, class Context,
           class Formatter = typename Context::template formatter_type&lt;remove_const_t&lt;T&gt;&gt;&gt;
    concept <i>formattable-with</i> =         <i>// exposition only</i>
      semiregular&lt;Formatter&gt; &amp;&amp;
        requires (Formatter&amp; f, const Formatter&amp; cf, T&amp;&amp; t, Context fc,
                 basic_format_parse_context&lt;typename Context::char_type&gt; pc)
       {
         { f.parse(pc) } -&gt; same_as&lt;typename decltype(pc)::iterator&gt;;
         { cf.format(t, fc) } -&gt; same_as&lt;typename Context::iterator&gt;;
       };</ins>

template&lt;class T, class charT&gt;
  concept formattable =
<del>    semiregular&lt;formatter&lt;remove_cvref_t&lt;T&gt;, charT&gt;&gt; &amp;&amp;
    requires(formatter&lt;remove_cvref_t&lt;T&gt;, charT&gt; f,
             const formatter&lt;remove_cvref_t&lt;T&gt;, charT&gt; cf,
             T t,
             basic_format_context&lt;<i>fmt-iter-for</i>&lt;charT&gt;, charT&gt; fc,
             basic_format_parse_context&lt;charT&gt; pc) {
        { f.parse(pc) } -&gt; same_as&lt;basic_format_parse_context&lt;charT&gt;::iterator&gt;;
        { cf.format(t, fc) } -&gt; same_as&lt;<i>fmt-iter-for</i>&lt;charT&gt;&gt;;
    };</del>
    <ins><i>formattable-with</i>&lt;remove_reference_t&lt;T>, basic_format_context&lt;<i>fmt-iter-for</i>&lt;charT&gt;&gt;&gt;;</ins>
</pre></blockquote>

</li>

<li><p>Modify 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a> as indicated:</p>

<pre>
namespace std {
  template&lt;class Context&gt;
  class basic_format_arg {
  public:
    class handle;

  private:
    using char_type = typename Context::char_type;                              <i>// exposition only</i>

    variant&lt;monostate, bool, char_type,
            int, unsigned int, long long int, unsigned long long int,
            float, double, long double,
            const char_type*, basic_string_view&lt;char_type&gt;,
            const void*, handle&gt; value;                                         <i>// exposition only</i>

    template&lt;class T&gt; explicit basic_format_arg(T&amp;<del>&amp;</del> v) noexcept;                <i>// exposition only</i>
    <del>explicit basic_format_arg(float n) noexcept;                                <i>// exposition only</i></del>
    <del>explicit basic_format_arg(double n) noexcept;                               <i>// exposition only</i></del>
    <del>explicit basic_format_arg(long double n) noexcept;                          <i>// exposition only</i></del>
    <del>explicit basic_format_arg(const char_type* s);                              <i>// exposition only</i></del>

    <del>template&lt;class traits&gt;</del>
      <del>explicit basic_format_arg(</del>
        <del>basic_string_view&lt;char_type, traits&gt; s) noexcept;                       <i>// exposition only</i></del>

    <del>template&lt;class traits, class Allocator&gt;</del>
      <del>explicit basic_format_arg(</del>
        <del>const basic_string&lt;char_type, traits, Allocator>&amp; s) noexcept;          <i>// exposition only</i></del>

    <del>explicit basic_format_arg(nullptr_t) noexcept;                              <i>// exposition only</i></del>

    <del>template&lt;class T&gt;</del>
      <del>explicit basic_format_arg(T* p) noexcept;                                 <i>// exposition only</i></del>
</pre>
&hellip;
<blockquote>
<pre>
template&lt;class T&gt; explicit basic_format_arg(T&amp;<del>&amp;</del> v) noexcept;
</pre>
<blockquote>
<p>
-4- <i>Constraints:</i>
<ins><code>T</code> satisfies <code><i>formattable-with</i>&lt;Context&gt;</code>.</ins>
<del>The template specialization</del>
</p>
<blockquote><pre><del>
typename Context::template formatter_type&lt;remove_cvref_t&lt;T&gt;&gt;
</del></pre></blockquote>
<p><del>
meets the <i>BasicFormatter</i> requirements (28.5.6.1 <a href="https://wg21.link/formatter.requirements">[formatter.requirements]</a>). The extent to
which an implementation determines that the specialization meets the <i>BasicFormatter</i>
requirements is unspecified, except that as a minimum the expression
</del></p>
<blockquote><pre><del>
typename Context::template formatter_type&lt;remove_cvref_t&lt;T&gt;&gt;()
  .format(declval&lt;T&amp;&gt;(), declval&lt;Context&amp;&gt;())
</del></pre></blockquote>
<p><del>
shall be well-formed when treated as an unevaluated operand (7.2.3 <a href="https://wg21.link/expr.context">[expr.context]</a>).
</del></p>
<p><ins>-?- <i>Preconditions</i>:
If <code>decay_t&lt;T&gt;</code> is <code>char_type*</code> or <code>const char_type*</code>,
<code>static_cast&lt;const char_type*&gt;(v)</code> points to a NTCTS
(3.36 <a href="https://wg21.link/defns.ntcts">[defns.ntcts]</a>).</ins>
</p>
<p>
-5- <i>Effects:</i>
<ins>Let <code>TD</code> be <code>remove_const_t&lt;T&gt;</code>.</ins>
</p>
<ol style="list-style-type:none">
<li><p>(5.1) &mdash; <ins>If</ins> <del>if</del> <code>T<ins>D</ins></code> is <code>bool</code> or <code>char_type</code>, initializes <code>value</code> with <code>v</code>;</p></li>
<li><p>(5.2) &mdash; otherwise, if <code>T<ins>D</ins></code> is <code>char</code> and <code>char_type</code> is <code>wchar_t</code>,
initializes <code>value</code> with <code>static_cast&lt;wchar_t&gt;(v)</code>;</p></li>
<li><p>(5.3) &mdash; otherwise, if <code>T<ins>D</ins></code> is a signed integer type (6.9.2 <a href="https://wg21.link/basic.fundamental">[basic.fundamental]</a>) and
<code>sizeof(T<ins>D</ins>) &lt;= sizeof(int)</code>, initializes <code>value</code> with <code>static_cast&lt;int&gt;(v)</code>;</p></li>
<li><p>(5.4) &mdash; otherwise, if <code>T<ins>D</ins></code> is an unsigned integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(unsigned int)</code>,
initializes <code>value</code> with <code>static_cast&lt;unsigned int&gt;(v)</code>;</p></li>
<li><p>(5.5) &mdash; otherwise, if <code>T<ins>D</ins></code> is a signed integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(long long int)</code>,
initializes <code>value</code> with <code>static_cast&lt;long long int&gt;(v)</code>;</p></li>
<li><p>(5.6) &mdash; otherwise, if <code>T<ins>D</ins></code> is an unsigned integer type and <code>sizeof(T<ins>D</ins>) &lt;= sizeof(unsigned long long int)</code>, initializes <code>value</code> with <code>static_cast&lt;unsigned long long int&gt;(v)</code>;</p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>TD</code> is a standard floating-point type, initializes <code>value</code> with <code>v</code>;</ins></p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>TD</code> is a specialization of
<code>basic_string_view</code> or <code>basic_string</code> and <code>TD::value_type</code> is <code>char_type</code>, initializes <code>value</code> with <code>basic_string_view&lt;char_type&gt;(v.data(), v.size())</code>;</ins></p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>decay_t&lt;TD&gt;</code> is <code>char_type*</code> or <code>const char_type*</code>, initializes <code>value</code> with <code>static_cast&lt;const char_type*&gt;(v)</code>;</ins></p></li>

<li><p><ins>(5.?) &mdash; otherwise, if <code>is_void_v&lt;remove_pointer_t&lt;TD&gt;&gt;</code> is <code>true</code> or <code>is_null_pointer_v&lt;TD&gt;</code> is <code>true</code>, initializes <code>value</code> with <code>static_cast&lt;const void*&gt;(v)</code>;</ins></p></li>

<li><p>(5.7) &mdash; otherwise, initializes <code>value</code> with <code>handle(v)</code>.</p></li>
</ol>
<p><ins>-?- [<i>Note</i>: Constructing <code>basic_format_arg</code> from a pointer
to a member is ill-formed unless the user provides an enabled specialization
of <code>formatter</code> for that pointer to member type. &mdash; <i>end note</i>]
</ins></p>
</blockquote>

<pre><del>
explicit basic_format_arg(float n) noexcept;
explicit basic_format_arg(double n) noexcept;
explicit basic_format_arg(long double n) noexcept;
</del></pre>
<blockquote>
<p><del>-6- <i>Effects</i>: Initializes <code>value</code> with <code>n</code>.</del></p>
</blockquote>

<pre><del>
explicit basic_format_arg(const char_type* s) noexcept;
</del></pre>
<blockquote>
<p><del>-7- <i>Preconditions</i>: <code>s</code> points to a NTCTS (3.36 <a href="https://wg21.link/defns.ntcts">[defns.ntcts]</a>).</del></p>
<p><del>-8- <i>Effects</i>: Initializes <code>value</code> with <code>s</code>.</del></p>
</blockquote>

<pre><del>
template&lt;class traits&gt;>
  explicit basic_format_arg(basic_string_view&lt;char_type, traits&gt; s) noexcept;
</del></pre>
<blockquote>
<p><del>-9- <i>Effects</i>: Initializes <code>value</code> with <code>basic_string_view&lt;char_type&gt;(s.data(), s.size())</code>.</del></p>
</blockquote>

<pre><del>
template&lt;class traits, class Allocator&gt;>
  explicit basic_format_arg(
    const basic_string&lt;char_type, traits, Allocator&gt;&amp; s) noexcept;
</del></pre>
<blockquote>
<p><del>-10- <i>Effects</i>: Initializes <code>value</code> with <code>basic_string_view&lt;char_type&gt;(s.data(), s.size())</code>.</del></p>
</blockquote>

<pre><del>
explicit basic_format_arg(nullptr_t) noexcept;
</del></pre>
<blockquote>
<p><del>-11- <i>Effects</i>: Initializes <code>value</code> with <code>static_cast&lt;const void*&gt;(nullptr)</code>.</del></p>
</blockquote>

<pre><del>
template&lt;class T&gt; explicit basic_format_arg(T* p) noexcept;
</del></pre>
<blockquote>
<p><del>-12- <i>Constraints</i>: <code>is_void_v&lt;T&gt;</code> is <code>true</code>.</del></p>
<p><del>-13- <i>Effects</i>: Initializes <code>value</code> with <code>p</code>.</del></p>
<p><del>-14- <i>[Note</i>: Constructing <code>basic_format_arg</code> from a pointer
to a member is ill-formed unless the user provides an enabled specialization
of <code>formatter</code> for that pointer to member type. &mdash; <i>end note]</i>
</del></p>
</blockquote>

</blockquote>
</li>

<li><p>Modify 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a> p17 and p18 as indicated:</p>

<blockquote>
<pre>
template&lt;class T&gt; explicit handle(T&amp;<del>&amp;</del> v) noexcept;
</pre>
<blockquote>
<p>-17- Let</p>
<ol style="list-style-type:none">
<li><p>&mdash; (17.1)
<code>TD</code> be <code>remove_<del>cvref</del><ins>const</ins>_t&lt;T&gt;</code>,
</p></li>
<li><p><del>&mdash; (17.2)
<code><i>const-formattable</i></code> be <code>true</code> if
<code>typename Context::template formatter_type&lt;TD&gt;().format(declval&lt;const TD&amp;&gt;(), declval&lt;Context&amp;&gt;())</code>
is well-formed, otherwise <code>false</code>,</del>
</p></li>
<li><p>&mdash; (17.3)
<code>TQ</code> be <code>const TD</code> if
<del><code><i>const-formattable</i></code> is <code>true</code></del>
<ins><code>const TD</code> satisfies <code><i>formattable-with</i>&lt;Context&gt;</code></ins>
and <code>TD</code> otherwise.
</p></li>
</ol>
<p>-18- <i>Mandates</i>:
<del><code><i>const-formattable</i>
|| !is_const_v&lt;remove_reference_t&lt;T&gt;&gt;</code> is <code>true</code>.</del>
<ins><code>TQ</code> satisfies <code><i>formattable-with</i>&lt;Context&gt;</code>.</ins>
</p>
<p>-19- <i>Effects</i>:
Initializes <code>ptr_</code> with <code>addressof(val)</code> and <code>format_</code> with
<blockquote><pre>
[](basic_format_parse_context&lt;char_type&gt;&amp; parse_ctx,
   Context&amp; format_ctx, const void* ptr) {
  typename Context::template formatter_type&lt;TD&gt; f;
  parse_ctx.advance_to(f.parse(parse_ctx));
  format_ctx.advance_to(f.format(*const_cast&lt;TQ*&gt;(static_cast&lt;const TD*&gt;(ptr)),
                                 format_ctx));
}
</pre></blockquote>
</p>
</blockquote>
</blockquote>
</li>

<li><p>Modify 28.5.8.2 <a href="https://wg21.link/format.arg.store">[format.arg.store]</a> p2 as indicated:</p>

<blockquote>
<pre>
template&lt;class Context = format_context, class... Args&gt;
  <i>format-arg-store</i>&lt;Context, Args...&gt; make_format_args(Args&amp;&amp;... fmt_args);
</pre>
<blockquote>
<p>-2- <i>Preconditions</i>: The type
<code>typename Context::template formatter_type&lt;<ins>remove_cvref_t&lt;</ins>T</code><sub>i</sub><code><ins>&gt;</ins>&gt;</code>
meets the <i>BasicFormatter</i> requirements (28.5.6.1 <a href="https://wg21.link/formatter.requirements">[formatter.requirements]</a>) for each <code>T</code><sub>i</sub>
in <code>Args</code>.
</p>
</blockquote>
</blockquote>

</li>
</ol>







</body>
</html>
