path lexically_normal() const;
Returns: A path whose pathname in the generic format is the normal form of the pathname in the generic format of *this.
[ Example:
assert(path("foo/./bar/..").lexically_normal() == "foo/"); assert(path("foo/.///bar/../").lexically_normal() == "foo/");
The above assertions will succeed. On Windows, the returned path's directory-separator characters will be backslashes rather than slashes, but that does not affect path equality. — end example ]
path lexically_relative(const path& base) const;
Effects: If root_name() != base.root_name() is true or is_absolute() != base.is_absolute() is true or !has_root_directory() && base.has_root_directory() is true, returns path(). Determines the first mismatched element of *this and base as if by:
auto [a, b] = mismatch(begin(), end(), base.begin(), base.end());
Then,
if a == end() and b == base.end(), returns path("."); otherwise
let n be the number of filename elements in [b, base.end()) that are not dot or dot-dot minus the number that are dot-dot. If n<0, returns path(); otherwise
returns an object of class path that is default-constructed, followed by
application of operator/=(path("..")) n times, and then
application of operator/= for each element in [a, end()).
[ Example:
assert(path("/a/d").lexically_relative("/a/b/c") == "../../d"); assert(path("/a/b/c").lexically_relative("/a/d") == "../b/c"); assert(path("a/b/c").lexically_relative("a") == "b/c"); assert(path("a/b/c").lexically_relative("a/b/c/x/y") == "../.."); assert(path("a/b/c").lexically_relative("a/b/c") == "."); assert(path("a/b").lexically_relative("c/d") == "../../a/b");
The above assertions will succeed. On Windows, the returned path's directory-separator characters will be backslashes rather than slashes, but that does not affect path equality. — end example ]
[ Note: If symlink following semantics are desired, use the operational function relative(). — end note ]
[ Note: If normalization is needed to ensure consistent matching of elements, apply lexically_normal() to *this, base, or both. — end note ]
path lexically_proximate(const path& base) const;
Returns: If the value of lexically_relative(base) is not an empty path, return it. Otherwise return *this.
[ Note: If symlink following semantics are desired, use the operational function proximate(). — end note ]
[ Note: If normalization is needed to ensure consistent matching of elements, apply lexically_normal() to *this, base, or both. — end note ]