<div dir="ltr"><div dir="ltr"><div dir="ltr">A single path is not conceptually a "range" of <i><b>anything</b></i> — it's just a single filesystem path.<div>C++17 made the mistake of giving "begin" and "end" methods to `std::filesystem::path`, so that to C++ a std::filesystem::path <i><b>looks</b></i> like a range of paths.</div><div>What it should have done was to give `std::filesystem::path` one or more "range accessor" methods:</div><div> for (auto&& component : mypath.components()) { ... }</div><div><div> for (auto&& character : mypath.str()) { ... }</div></div><div><br></div><div>Niall, if you are actively pursuing `path_view` for C++2b, please try to avoid making the same mistakes that <filesystem> made!</div><div><br></div><div>Thanks,</div><div>–Arthur</div><div><br></div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 22, 2019 at 9:45 AM Herring, Davis via Lib-Ext <<a href="mailto:lib-ext@lists.isocpp.org">lib-ext@lists.isocpp.org</a>> wrote:<br></div><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">> It has been brought to my attention by Victor Zverovich that<br>
> filesystem::path has an unfortunate quirk wrt Ranges:<br>
> filesystem::path::iterator::value_type is filesystem::path.<br>
<br>
This was (my) Late 19 comment for C++17. (At the time, I proposed just using string for the individual components, but it's still helpful to have path's encoding support.) It's also a famous pitfall in Python:<br>
<br>
def depth(x,f): # apply f to all leaves<br>
try: x=iter(x)<br>
except TypeError: f(x)<br>
else:<br>
for e in x: depth(e,f)<br>
<br>
depth("a",id) will recurse forever because list("a")[0]=="a".<br>
<br>
Davis<br>
_______________________________________________<br>
Lib-Ext mailing list<br>
<a href="mailto:Lib-Ext@lists.isocpp.org" target="_blank">Lib-Ext@lists.isocpp.org</a><br>
Subscription: <a href="https://lists.isocpp.org/mailman/listinfo.cgi/lib-ext" rel="noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/lib-ext</a><br>
Link to this post: <a href="http://lists.isocpp.org/lib-ext/2019/08/12453.php" rel="noreferrer" target="_blank">http://lists.isocpp.org/lib-ext/2019/08/12453.php</a><br>
</blockquote></div>