<div dir="ltr"><div dir="ltr"><div dir="ltr">On Tue, Aug 27, 2019 at 7:53 AM Niall Douglas via Lib-Ext &lt;<a href="mailto:lib-ext@lists.isocpp.org">lib-ext@lists.isocpp.org</a>&gt; wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On 26/08/2019 22:32, David Stone wrote:<br>
&gt; I have several times written (and seen written) code like<br>
&gt; <br>
&gt;     auto directory = std::filesystem::path(...);<br>
&gt;     for (auto const &amp; path : directory) {<br>
&gt;         use(path);<br>
&gt;     }<br>
&gt; <br>
&gt; when what I meant was<br>
&gt; <br>
&gt;     auto directory = std::filesystem::path(...);<br>
&gt;     for (auto path_it = std::filesystem::directory_iterator(directory);<br>
&gt; path_it != std::filesystem::directory_iterator(); ++path_it) {<br>
&gt;         use(*path_it);<br>
&gt;     }<br>
<br>
I&#39;d have some sympathy for you if you had written:<br>
<br>
     auto directory = std::filesystem::path(...);<br>
     for (auto const &amp; path : *directory) {<br>
         use(path);<br>
     }<br>
<br>
... and you did not get directory enumeration, as it would be reasonable<br>
to expect dereferencing a path might do something like contents enumeration.<br>
<br>
But if you iterate a container of X, you expect to yield X.</blockquote><div><br></div><div>Well, I can see the logic for someone naively assuming that &quot;/usr/local&quot; would be a &#39;container&#39; holding &quot;/usr/local/include&quot;, &quot;/usr/local/bin&quot;, &quot;/usr/local/lib&quot;, and so on. That&#39;s <i><b>very roughly</b></i> what happens at the filesystem level when you do an `ls`.  It wouldn&#39;t be very &quot;C++-ish&quot; to design the actual class type that way, but a naive user by definition doesn&#39;t know that.</div><div><br></div><div>A user who has worked in C++ for a while, and knows that C++ treats paths essentially as strings, might naively assume that &quot;/usr/local&quot; was a string-style &#39;container&#39; holding &#39;/&#39;, &#39;u&#39;, &#39;s&#39;, &#39;r&#39;, &#39;/&#39;, &#39;l&#39;, &#39;o&#39;, &#39;c&#39;, &#39;a&#39;, and &#39;l&#39;.  (They might even verify that `path::value_type` is a character type. It is.)  As you say, for historical reasons that&#39;s not what the Committee gave us; but a user who merely <i><b>uses</b></i> C++ by definition doesn&#39;t know committee political history.</div><div><br></div><div>Any user is surprised (the first time) when &quot;/usr/local&quot; turns out to be a &#39;container&#39; holding the meaningless fragments &quot;/&quot;, &quot;usr&quot;, and &quot;local&quot;.</div><div><br></div><div>–Arthur<br></div></div></div></div>