std::filesystem::path::append oddity
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Jun 18 08:06:00 GMT 2018
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};
More information about the Gcc-help
mailing list