<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2798: Definition of path in terms of a string</title>
<meta property="og:title" content="Issue 2798: Definition of path in terms of a string">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2798.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="2798"><a href="lwg-defects.html#2798">2798</a>. Definition of path in terms of a string</h3>
<p><b>Section:</b> 31.12.6 <a href="https://wg21.link/fs.class.path">[fs.class.path]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Billy O'Neal III <b>Opened:</b> 2016-11-10 <b>Last modified:</b> 2017-07-18</p>
<p><b>Priority: </b>2
</p>
<p><b>View all other</b> <a href="lwg-index.html#fs.class.path">issues</a> in [fs.class.path].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<b>Addresses US 44, LWG <a href="lwg-defects.html#2734" title="Questionable specification in [fs.path.concat] (Status: Resolved)">2734</a><sup><a href="https://cplusplus.github.io/LWG/issue2734" title="Latest snapshot">(i)</a></sup></b>
<p/>
The explicit definition of <code>path</code> in terms of a string 
requires that the abstraction be leaky. Consider that 
the meaning of the expression <code>p += '/'</code>  has very 
different behavior in the case that <code>p</code> is empty; that a 
<code>path</code> can uselessly contain null characters; and that 
iterators must be constant to avoid having to reshuffle 
the packed string.
</p>
<p>
Suggested resolution:
<p/>
Define member functions to express a <code>path</code> as a 
string, but define its state in terms of the abstract 
sequence of components (including the leading 
special components) already described by the 
iterator interface. Remove members that rely on 
arbitrary manipulation of a string value.
</p>
<p><i>[2016-11-12, Issaquah]</i></p>

<p>Sat PM: "Looks good"</p>

<p><i>[Issues Telecon 16-Dec-2016]</i></p>

<p>Priority 2; should be addressed by omnibus Filesystem paper.</p>

<p><i>[Kona, 2017-03]</i></p>

<p>This is resolved by p0492r2.</p>


<p id="res-2798"><b>Proposed resolution:</b></p>
<p>This wording is relative to N4606.</p>

<ol>
<li>
<p>Edit [fs.path.concat] as follows:</p>

<blockquote>
<pre>
path&amp; operator+=(const path&amp; x);
path&amp; operator+=(const string_type&amp; x);
path&amp; operator+=(basic_string_view&lt;value_type&gt; 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);
<del>template &lt;class InputIterator&gt;
    path&amp; concat(InputIterator first, InputIterator last);</del>
</pre>
<blockquote>
<p>
-1- <del><em>Postcondition:</em> <code>native() == prior_native + <em>effective-argument</em></code>, 
where <code>prior_native</code> is <code>native()</code> prior to the call to <code>operator+=</code>, and 
<code><em>effective-argument</em></code> is:</del>
</p>
<ul>
    <li><del>if <code>x</code> is present and is <code>const path&amp;</code>, <code>x.native()</code>; otherwise,</del></li>
    <li><del>if <code>source</code> is present, the effective range of <code>source</code>  [ath.re]; 
    otherwise,</del></li>
    <li><del>>if <code>first</code> and <code>last</code> are present, the range <code>[first, last)</code>; otherwise,</del></li>
    <li><del><code>x</code>.</del></li>
</ul>
<p>
<del>If the value type of <code><em>effective-argument</em></code> would not be <code>path::value_type</code>, 
the acctual argument or argument range is first converted  [ath.type.cv] so 
that <code><em>effective-argument</em></code> has value type <code>path::value_type</code>.</del>
<ins><em>Effects:</em> Equivalent to <code>pathname.append(path(x).native())</code> [<em>Note:</em> 
This directly manipulates the value of <code>native()</code> and may not be portable between operating systems. 
&mdash; <em>end note</em>]</ins>
<p/>
-2- <em>Returns:</em> <code>*this</code>.
</p>
</blockquote>
<pre>
<ins>template &lt;class InputIterator&gt;
    path&amp; concat(InputIterator first, InputIterator last);</ins>
</pre>
<blockquote>
<p>
<ins>-?- <em>Effects:</em> Equivalent to <code>pathname.append(path(first, last).native())</code> [<em>Note:</em> This 
directly manipulates the value of <code>native()</code> and may not be portable between operating systems. &mdash; 
<em>end note</em>]</ins>
<p/>
<ins>-?- <em>Returns:</em> <code>*this</code>.</ins>
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
