I ... really don't understand how the `std::filesystem::path` API is usable. Do others not find this *terribly* hard to read and understand?

From en.cppreference.com/w/cpp/file:

```cpp
path("foo") / "" // the result is "foo/" (appends)
path("foo") / "/bar"; // the result is "/bar" (replaces)
```

And yes, TIL that this is how it works.

Just to be explicit -- my question is not rhetorical at all. I would like to hear from folks who don't find this confusing so I can understand better how they are reading and thinking about the code.

Follow

@chandlerc

It sounds sane to me. The alternative, where `path("/foo") / "/bar"` would mean "/foo/bar" would be extremely confusing, because we then sometimes _silently_ strip the path of its absoluteness (in second argument of `operator/()`), but in other cases we don't. Another variant that'd be not that confusing for me is having `path("/foo") / "/anything/absolute"` error out in some fashion.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.