<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3810: CTAD for std::basic_format_args</title>
<meta property="og:title" content="Issue 3810: CTAD for std::basic_format_args">
<meta property="og:description" content="C++ library issue. Status: C++23">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3810.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="3810"><a href="lwg-defects.html#3810">3810</a>. CTAD for <code>std::basic_format_args</code></h3>
<p><b>Section:</b> 28.5.8.3 <a href="https://wg21.link/format.args">[format.args]</a> <b>Status:</b> <a href="lwg-active.html#C++23">C++23</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2022-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.args">issues</a> in [format.args].</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>
It seems desirable for this should work:
</p>
<blockquote><pre>
auto args_store = std::make_format_args&lt;C&gt;(1,2,3);
// &hellip;
std::basic_format_args args = args_store;
</pre></blockquote>
<p>
i.e. CTAD should deduce the <code>Context</code> argument from the <code><i>fmt-store-args</i>&lt;C, int, int, int&gt;</code> 
object returned by <code>make_format_args</code>.
<p/>
Another example (from Tomasz Kami&nacute;ski):
<p/>
Given:
</p>
<blockquote><pre>
template&lt;typename Context&gt;
void foo(basic_format_args&lt;Context&gt; c);

foo(make_format_args&lt;SomeContext&gt;(&hellip;)); // won't work
foo(basic_format_args(make_format_args&lt;SomeContext&gt;(&hellip;))); // should work
</pre></blockquote>
<p>
Since <code><i>fmt-store-args</i></code> is exposition-only, it's not entirely clear that it must have 
exactly the form shown in 28.5.8.2 <a href="https://wg21.link/format.arg.store">[format.arg.store]</a>. E.g. maybe it can have different template arguments, 
or could be a nested type defined inside <code>basic_format_args</code>. I don't know how much of the exposition-only 
spec is actually required for conformance. If CTAD is already intended to be required, it's a bit subtle.
<p/>
If we want the CTAD to work (and I think it's nice if it does) we could make that explicit by adding a deduction guide.
</p>

<p><i>[Kona 2022-11-12; Set priority to 3, status to LEWG]</i></p>


<p><i>[2023-01-10; LEWG telecon]</i></p>

<p>Unanimous consensus in favor.</p>

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

<p>Unanimous consent (9/0/0) to 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-3810"><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.8.3 <a href="https://wg21.link/format.args">[format.args]</a> as indicated:</p>

<blockquote>
<pre>
namespace std {
  template&lt;class Context&gt;
  class basic_format_args {
    size_t size_;                           <i>// exposition only</i>
    const basic_format_arg&lt;Context&gt;* data_; <i>// exposition only</i>

  public:
    basic_format_args() noexcept;

    template&lt;class... Args&gt;
      basic_format_args(const <i>format-arg-store</i>&lt;Context, Args...&gt;&amp; store) noexcept;

    basic_format_arg&lt;Context&gt; get(size_t i) const noexcept;
  };
  
  <ins>template&lt;class Context, class... Args&gt;
    basic_format_args(<i>format-arg-store</i>&lt;Context, Args...&gt;) -&gt; basic_format_args&lt;Context&gt;;</ins>
}
</pre>
</blockquote>
</li>

</ol>





</body>
</html>
