<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2732: Questionable specification of path::operator/= and path::append</title>
<meta property="og:title" content="Issue 2732: Questionable specification of path::operator/= and path::append">
<meta property="og:description" content="C++ library issue. Status: C++17">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2732.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++17">C++17</a> status.</em></p>
<h3 id="2732"><a href="lwg-defects.html#2732">2732</a>. Questionable specification of <code>path::operator/=</code> and <code>path::append</code></h3>
<p><b>Section:</b> 31.12.6.5.3 <a href="https://wg21.link/fs.path.append">[fs.path.append]</a> <b>Status:</b> <a href="lwg-active.html#C++17">C++17</a>
 <b>Submitter:</b> Tim Song <b>Opened:</b> 2016-06-14 <b>Last modified:</b> 2017-07-30</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.path.append">issues</a> in [fs.path.append].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++17">C++17</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The current specification of <code>operator/=</code> taking a <code>const Source&amp;</code> parameter, and of 
<code>path::append</code> in 31.12.6.5.3 <a href="https://wg21.link/fs.path.append">[fs.path.append]</a> appears to require <code>Source</code> to have a <code>native()</code> 
and an <code>empty()</code> member, and seemingly requires different behavior for <code>append(<i>empty_range</i>)</code> 
and <code>append(first, last)</code> when <code>first == last</code> (the last two bullet points being specified with 
<code>source</code> alone), which doesn't make any sense.
<p/>
It appears that these overloads can just be specified using the <code>operator/=(const path&amp;)</code> overload.
</p>

<p><i>[2016-07-03, Daniel comments]</i></p>

<p>
The same wording area is affected by LWG <a href="lwg-defects.html#2664" title="operator/ (and other append) semantics not useful if argument has root (Status: C++17)">2664</a><sup><a href="https://cplusplus.github.io/LWG/issue2664" title="Latest snapshot">(i)</a></sup>.
</p>

<p><i>[2016-08 Chicago]</i></p>

<p>Wed AM: Move to Tentatively Ready</p>

<p>Friday AM, in discussing <a href="lwg-defects.html#2664" title="operator/ (and other append) semantics not useful if argument has root (Status: C++17)">2664</a><sup><a href="https://cplusplus.github.io/LWG/issue2664" title="Latest snapshot">(i)</a></sup> a comment about missing "equivalent to" language
was made, so PR updated.</p>

<p><strong>Previous Resolution [SUPERSEDED]</strong></p>
<blockquote class="note">
<p>This wording is relative to N4594.</p>
<ol>
<li><p>Edit 31.12.6.5.3 <a href="https://wg21.link/fs.path.append">[fs.path.append]</a>/4-5 as indicated:</p>

<blockquote>
<pre>
template &lt;class Source&gt;
  path&amp; operator/=(const Source&amp; source);
template &lt;class Source&gt;
  path&amp; append(const Source&amp; source);
</pre>
<blockquote>
<p>
<ins>-?- <i>Effects:</i> <code>operator/=(path(source))</code></ins>
<p/>
<ins>-?- <i>Returns:</i> <code>*this</code>.</ins>
</p>
</blockquote>
<pre>
template &lt;class InputIterator&gt;
  path&amp; append(InputIterator first, InputIterator last);
</pre>
<blockquote>
<p>
-4- <i>Effects:</i> <del>Appends <code>path::preferred_separator</code> to <code>pathname</code>, converting format and encoding
if required (31.12.6.3 <a href="https://wg21.link/fs.path.cvt">[fs.path.cvt]</a>), unless:</del>
</p>
<ul>
<li><p><del>an added <i>directory-separator</i> would be redundant, or</del></p></li>
<li><p><del>an added <i>directory-separator</i> would change an relative path to an absolute path, or</del></p></li>
<li><p><del><code>source.empty()</code> is <code>true</code>, or</del></p></li>
<li><p><del><code>*source.native().cbegin()</code> is a <i>directory-separator</i>.</del></p></li>
</ul>
<p>
<del>Then appends the effective range of <code>source</code> (31.12.6.4 <a href="https://wg21.link/fs.path.req">[fs.path.req]</a>) or the range <code>[first, last)</code> to
<code>pathname</code>, converting format and encoding if required
(31.12.6.3 <a href="https://wg21.link/fs.path.cvt">[fs.path.cvt]</a>)</del><ins><code>operator/=(path(first, last))</code></ins>.
<p/>
-5- <i>Returns:</i> <code>*this</code>.
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>


<p id="res-2732"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4606.</p>
<ol>
<li><p>Edit 31.12.6.5.3 <a href="https://wg21.link/fs.path.append">[fs.path.append]</a>/4-5 as indicated:</p>

<blockquote>
<pre>
template &lt;class Source&gt;
  path&amp; operator/=(const Source&amp; source);
template &lt;class Source&gt;
  path&amp; append(const Source&amp; source);
</pre>
<blockquote>
<p><ins>-?- <i>Effects:</i> Equivalent to <code>return operator/=(path(source));</code>.</ins></p>
</blockquote>
<pre>
template &lt;class InputIterator&gt;
  path&amp; append(InputIterator first, InputIterator last);
</pre>
<blockquote>
<p>-4- <i>Effects:</i> <ins>Equivalent to <code>return operator/=(path(first, last));</code>.</ins><del>Appends <code>path::preferred_separator</code> to <code>pathname</code>,
converting format and encoding if required (31.12.6.3 <a href="https://wg21.link/fs.path.cvt">[fs.path.cvt]</a>), unless:</del></p>
<ol style="list-style-type: none">
<li><del>&mdash; an added <i>directory-separator</i> would be redundant, or</del></li>
<li><del>&mdash; an added <i>directory-separator</i> would change an relative path to an absolute
path, or</del></li>
<li><del>&mdash; <code>source.empty()</code> is <code>true</code>, or</del></li>
<li><del>&mdash; <code>*source.native().cbegin()</code> is a <i>directory-separator</i>.</del></li>
</ol>
<p><del>Then appends the effective range of <code>source</code> (31.12.6.4 <a href="https://wg21.link/fs.path.req">[fs.path.req]</a>) or the
range <code>[first, last)</code> to <code>pathname</code>, converting format and encoding if required
(31.12.6.3 <a href="https://wg21.link/fs.path.cvt">[fs.path.cvt]</a>).</del></p>
<p><del>-5- <i>Returns:</i> <code>*this</code>.</del></p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
