This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: std::filesystem::path::append oddity
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: NightStrike <nightstrike at gmail dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Mon, 18 Jun 2018 09:04:44 +0100
- Subject: Re: std::filesystem::path::append oddity
- References: <CAF1jjLv2=GOmaEVfD82mzvtp=aCrPdXgXQ5u-37g=VqB1VMW=g@mail.gmail.com>
On Sun, 17 Jun 2018 at 23:01, NightStrike <nightstrike@gmail.com> wrote:
>
> I'm probably missing something abundantly obvious here, but shouldn't these
> two methods of appending be the same according to
> https://en.cppreference.com/w/cpp/filesystem/path/append variants 2 and 3?
https://en.cppreference.com/w/cpp/filesystem/path/append#Parameters
seems pretty clear about the allowed parameters of the (2) and (3)
overloads.
Neither of them can be called with a path object.
>
> #include <filesystem>
> #include <string>
> namespace fs = std::filesystem;
>
> void f() {
> fs::path p;
> p /= fs::path("s"); // works
This works because it calls (1).
> p.append(fs::path("s")); // doesn't
This is neither a valid argument for the "source" parameter, nor a
pair of iterators.
> }
>
> It appears like clang doesn't support it, either. The downside here is
> that it prevents being able to do the following:
>
> ifstream if { p.append(...).c_str() };
It's a lot simpler to just do:
ifstream if{p/q};