Re: [boost] [1.44] [filesystem] operator +

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 -Jochen

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. -- Lars Viklund | zao@acc.umu.se

On Tue, Aug 24, 2010 at 7:05 AM, Lars Viklund <zao@acc.umu.se> 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

On 24 August 2010 01:58, Jochen Wilhelmy <j.wilhelmy@arcor.de> wrote:
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
path p1 = "foo/bar.xml"; path p2 = path(p1).replace_extension(".dat");
participants (4)
-
Beman Dawes
-
Jochen Wilhelmy
-
Lars Viklund
-
Scott McMurray