C++ Logo

sg16

Advanced search

Re: [SG16-Unicode] [isocpp-lib-ext] Proposed design change to P1030 filesystem::path_view

From: David Stone <david.stone_at_[hidden]>
Date: Mon, 26 Aug 2019 15:32:32 -0600
I have several times written (and seen written) code like

    auto directory = std::filesystem::path(...);
    for (auto const & path : directory) {
        use(path);
    }

when what I meant was

    auto directory = std::filesystem::path(...);
    for (auto path_it = std::filesystem::directory_iterator(directory);
path_it != std::filesystem::directory_iterator(); ++path_it) {
        use(*path_it);
    }

but I have never intentionally iterated over the components of the path
(and if I did, I would expect to need to apply some transformation to get
that).

I have to agree with Arthur that this is a big source of errors in the
existing API and should not be used as a precedent if at all possible.

Received on 2019-08-26 23:32:44