Boost logo

Boost :

Subject: Re: [boost] [filesystem] Request for comments on proposed relative() function
From: Daniel Pfeifer (daniel_at_[hidden])
Date: 2014-05-15 07:50:46


2014-05-14 11:02 GMT+02:00 Rob Stewart <robertstewart_at_[hidden]>:
> On May 9, 2014 4:23:00 PM EDT, Daniel Pfeifer <daniel_at_[hidden]> wrote:
>>2014-05-08 21:02 GMT+02:00 Bjorn Reese <breese_at_[hidden]>:
>>> On 05/08/2014 07:19 PM, Beman Dawes wrote:
>>>
>>>> Creates a path from the trailing elements of p that are relative
>>>> to base.
>>>
>>>
>>> It may be more user-friendly to add that base must be a prefix of p.
>>
>>It might be even more user-friendly to allow this use case:
>>
>>BOOST_TEST(fs::relative("/abc", "/abc/def") == path("../def"));
>
> The first element in the range p, that's not in base, is the empty set, so p cannot be made relative to base in your example. If you reverse the arguments, then the result would be "def".

My bad. I inteded to write:

BOOST_TEST(fs::relative("/abc", "/abc/def") == path(".."));
BOOST_TEST(fs::relative("/abc/def", "/abc/ghi") == path("../def"));

Here again, the first element in the range p, that's not in base, is
the empty set. So you say that this is not possible?
I see that the proposed implementation of fs::relative does not
support it, but I am very interested in this functionality.

-- Daniel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk