C++ Logo

std-discussion

Advanced search

Re: fs::path appenders have inconsistent behavior for UNC paths between OSes

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 04 Nov 2021 18:41:53 -0700
On Thursday, 4 November 2021 15:41:17 PDT Andrey Semashev via Std-Discussion
wrote:
> Besides the difference in behavior, the result of "/bar" seems
> unexpected, as appending a path starting with a root directory is
> expected to be rebased on top of the source's root name.
>
> My question is, is this behavior intentional or is this a defect? If it
> is intentional, what is the rationale?

It seems to me that you explained the rationale in your own email.

The operator/ will discard the left side if the right side is an absolute
path. Since "/bar" is an absolute path on POSIX systems, then the result of

  anything / "/bar"
is
 "/bar"

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2021-11-04 20:42:00