Boost logo

Boost :

Subject: Re: [boost] [1.44] [filesystem] operator +
From: Beman Dawes (bdawes_at_[hidden])
Date: 2010-08-24 11:14:11


On Tue, Aug 24, 2010 at 7:05 AM, Lars Viklund <zao_at_[hidden]> wrote:
> On Tue, Aug 24, 2010 at 10:58:23AM +0200, Jochen Wilhelmy wrote:
>>> > for boost::filesystem::path I would suggest an operator + that works
>> like
>>> > the following
>>> > fs::path("foo") + "bar" -> "foobar"
>>> > fs::path("foo") + "/bar" -> "foo/bar"
>>> > fs::path("foo") / "bar" -> "foo/bar"
>>> >
>> >What's the situation in which you'd like to use that operator?
>>
>> Sometimes I have file formats that have two parts, e.g. a description
>> xml file
>> and a data file. then I'd like to do name + ".xml" and name + ".dat" if
>> name is
>> a fs::path
>
> Note that Boost.Filesystem contains functions to retrieve and modify
> file extensions.
>
> In my opinion, introducing such a free + operator would be quite bad, as
> it would encourage use of it to glue on path segments in ways that may
> violate the format of paths for a platform, as in your example of an
> unconditional +"/bar", which would be horribly wrong for any platform
> that didn't use / as separator.

I agree.

I'd also like to avoid cluttering the class path interface with
functions that are of limited usefulness and easy for the user to
provide themselves.

--Beman


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