<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2734: Questionable specification in [fs.path.concat]</title>
<meta property="og:title" content="Issue 2734: Questionable specification in [fs.path.concat]">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2734.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#Resolved">Resolved</a> status.</em></p>
<h3 id="2734"><a href="lwg-defects.html#2734">2734</a>. Questionable specification in [fs.path.concat]</h3>
<p><b>Section:</b> 31.12.6.5.4 <a href="https://wg21.link/fs.path.concat">[fs.path.concat]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2016-06-16 <b>Last modified:</b> 2018-01-24</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.path.concat">issues</a> in [fs.path.concat].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
31.12.6.5.4 <a href="https://wg21.link/fs.path.concat">[fs.path.concat]</a> specifies that the postcondition for
</p>
<blockquote>
<pre>
path&amp; operator+=(const path&amp; x);
path&amp; operator+=(const string_type&amp; x);
path&amp; operator+=(const value_type* x);
path&amp; operator+=(value_type x);
template&lt;class Source&gt;
path&amp; operator+=(const Source&amp; x);
template&lt;class EcharT&gt;
path&amp; operator+=(EcharT x);
template&lt;class Source&gt; 
path&amp; concat(const Source&amp; x); 
template&lt;class InputIterator>
path&amp; concat(InputIterator first, InputIterator last);
</pre>
</blockquote>
<p>
is
</p>
<blockquote>
<p>
<code>native() == prior_native</code> + <i>effective-argument</i>
</p>
</blockquote>
<p>
where <i>effective-argument</i> is
</p>
<ol>
<li>if <code>x</code> is present and is <code>const path&amp;</code>, <code>x.native()</code>; otherwise</li>
<li>if <code>source</code> is present, the effective range of <code>source</code> (31.12.6.4 <a href="https://wg21.link/fs.path.req">[fs.path.req]</a>); otherwise,</li>
<li>if <code>first</code> and <code>last</code> are present, the range <code>[first, last)</code>; otherwise,</li>
<li><code>x</code></li>
</ol>
<p>
It also says that
</p>
<blockquote>
<p>
If the value type of <i>effective-argument</i> would not be <code>path::value_type</code>, the actual argument or 
argument range is first converted (31.12.6.3.2 <a href="https://wg21.link/fs.path.type.cvt">[fs.path.type.cvt]</a>) so that <i>effective-argument</i> has value 
type <code>path::value_type</code>.
</p>
</blockquote>
<p>
There are several problems with this specification:
<p/>
First, there is no overload taking "<code>source</code>" (note the lower case); all single-argument overloads take 
"<code>x</code>". Second, there's nothing that defines what it means to use <code>operator+</code> on a string and an 
iterator range; clearly concatentation is intended but there is no wording to that effect.
Third, the final portion uses "value type", but the "value type" of a single character is not a defined concept.
<p/>
Also, the reference only to 31.12.6.3.2 <a href="https://wg21.link/fs.path.type.cvt">[fs.path.type.cvt]</a> seems to imply that any format conversion specified in 
31.12.6.3.1 <a href="https://wg21.link/fs.path.fmt.cvt">[fs.path.fmt.cvt]</a> will not be performed, in seeming contradiction to the rule that <code>native()</code> 
is to return the native pathname format (31.12.6.5.6 <a href="https://wg21.link/fs.path.native.obs">[fs.path.native.obs]</a>/1). Is that intended?
</p>

<p><i>[2016-11-10, Billy suggests wording]</i></p>

<p>
The wording for LWG <a href="lwg-defects.html#2798" title="Definition of path in terms of a string (Status: Resolved)">2798</a><sup><a href="https://cplusplus.github.io/LWG/issue2798" title="Latest snapshot">(i)</a></sup> resolves this issue as well.
</p>


<p id="res-2734"><b>Proposed resolution:</b></p>
<p>This is resolved by p0492r2.</p>





</body>
</html>
