On Fri, 5 Nov 2021 at 03:58, Thiago Macieira via Std-Discussion <std-discussion@lists.isocpp.org> wrote:
On Thursday, 4 November 2021 18:58:57 PDT Andrey Semashev via Std-Discussion
wrote:
> That's not a rationale, it's a consequence of the specification. I'm
> interested in the motivation for the specification being written this
> way (if it was written so intentionally, with respect to the case I
> described).

It seems that operator/ is implemented like the "cd" command, not a string
concatenation.

Think of this:
$ cd /usr
$ cd /bin
$ pwd
/bin

You don't expect it to show /usr/bin (whether /bin is a symlink to /usr/bin or
not is irrelevant here).

I agree with you it's surprising at first sight because

        "//net/foo" + "/bar"

makes it a subdir of //net/foo.

But it's not meant to be like string concatenation.

The only prior art of operator/ that I know of is in the Meson buildsystem and
it behaves exactly like fs::path. See
https://mesonbuild.com/Syntax.html#string-path-building

For another, Python pathlib (in the standard library; https://docs.python.org/3/library/pathlib.html) behaves exactly the same; on Linux:

>>> Path('//net/foo') / Path('/bar')
PosixPath('/bar')

and on Windows,

>>> Path('//net/foo') / Path('/bar')
WindowsPath('//net/foo/bar')