
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 know that I can exchange the current extension, but how can I add one to a path that soes not have one? The current filename may already contain dots therefore the addition of an extension should not check if there is already one. (e.g. "foo/bar.xy" + ".zw" -> "foo/bar.xy.zw") I don't see any technical problem with + "/bar" since "/bar" is the platform independent notation and should therefore work on any platform. so far it is also allowed to do fs::path("foo/bar") where '/' is also the platform independent separator. therefore it should be equivalent to fs::path("foo") + "/bar". but it would be ok to prevent this e.g. by throwing an exception. something like path.add_extension(".bar") should be ok too. -Jochen