cplusplus / filesystem-ts

Library Enhancements Working Group
57 stars 15 forks source link

Bidirectional iterator requirement on path::iterator is very expensive. #18

Closed jwakely closed 9 years ago

jwakely commented 9 years ago

[path.itr] requires path::iterator to be a BidirectionalIterator, which also implies the ForwardIterator requirement in [forward.iterators] p6 , so the following assertion should pass:

path p("/");
auto it1 = p.begin();
auto it2 = p.begin();
assert( &*it1 == &*it2 );

This prevents iterators containing a path, or constructing one on the fly when dereferenced, the object they point to must exist outside the iterators and potentially outlive them. The only practical way to meet the requirement is for p to hold a container of child path objects so the iterators can refer to those children. This makes a path object much larger than would naïvely be expected.

The Boost and MSVC implementations of Filesystem fail to meet this requirement. The GCC implementation meets it, but it makes sizeof(path) == 64 (for 64-bit) or sizeof(path) == 40 for 32-bit, and makes many path operations more expensive.

Beman commented 9 years ago

Please check http://cplusplus.github.io/filesystem-ts/active.html#74

Thanks,

-Beman