Opened 11 years ago
Closed 7 years ago
#6249 closed Bugs (fixed)
boost::filesystem::path::append should be specialized for boost::filesystem::path::iterator
Reported by: | Owned by: | Beman Dawes | |
---|---|---|---|
Milestone: | Boost 1.60.0 | Component: | filesystem |
Version: | Boost 1.46.1 | Severity: | Problem |
Keywords: | append relative | Cc: |
Description
Currently the following is a no go:
boost::filesystem::path a("foo/bar"), b("test/korv"); a.append( b.begin() + 1, b.end() ); Expects a == "foo/bar/korv"
This is because append() is strictly for iterators of string types it would seem. I suggest adding the following specialization ( or something along these lines ):
template < > path& path::append< path::iterator >( path::iterator begin, path::iterator end, const codecvt_type& cvt) {
for( ; begin != end ; ++begin )
*this /= *begin;
return *this;
}
I've attached an example of make_relative which uses this functionality.
Attachments (1)
Change History (3)
by , 11 years ago
Attachment: | make_relative_append_example.cpp added |
---|
comment:1 by , 11 years ago
Component: | None → filesystem |
---|
comment:2 by , 7 years ago
Milestone: | To Be Determined → Boost 1.60.0 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Boost 1.60.0 will add functions lexically_normal, lexically_relative, relative, and weakly_canonical. These are designed to provide the equivalent to functionality requested by this ticket.
See http://boostorg.github.io/filesystem/relative_proposal.html for more information. It proposes additional lexical and operational proximate functions, but I have chosen not to include those now. They will be reconsidered once users get some field experience with the core functionality for computing relative paths.
These function are available now on the https://github.com/boostorg/filesystem develop branch, and will be merged to master as soon as sufficient regression tests have cycled. They will also be proposed for inclusion in the next version of the C++ committee's TS 18822, File System Technical Specification.
Many thanks to Jamie Allsop for his help and perseverance, and to everyone else who made suggestions and comments. Jamie's paper is available at https://github.com/ja11sop/std-filesystem-relative
Thanks,
--Beman