Title
Bidirectional iterator requirement on path::iterator is very expensive
Status
c++17
Section
[fs.path.itr]
Submitter
Jonathan Wakely

Created on 2015-09-15.00:00:00 last changed 89 months ago

Messages

Date: 2017-03-19.19:35:20

Proposed resolution:

This wording is relative to N4582.

  1. Change [fs.path.itr] paragraph 2:

    A path::iterator is a constant iterator satisfying all the requirements of a bidirectional iterator (C++14 §24.1.4 Bidirectional iterators) except that there is no requirement that two equal iterators be bound to the same object. Its value_type is path.

Date: 2016-04-10.22:23:37

[ Apr 2016 Issue updated to address the C++ Working Paper. Previously addressed File System TS ]

Date: 2016-01-28.01:00:35

[ 21 Nov 2015 Beman comments: ]

The ForwardIterator requirement in [forward.iterators] "If a and b are both dereferenceable, then a == b if and only if *a and *b are bound to the same object." will be removed by N4560, Working Draft, C++ Extensions for Ranges. I see no point in requiring something for the File System TS that is expensive, has never to my knowledge been requested by users, and is going to go away soon anyhow. The wording I propose below removes the requirement.

Date: 2017-03-19.19:35:20

[fs.path.itr] requires path::iterator to be a BidirectionalIterator, which also implies the ForwardIterator requirement in [forward.iterators] p6 for the following assertion to 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.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-06-28 12:50:44adminsetstatus: ready -> wp
2016-04-16 04:56:37adminsetstatus: new -> ready
2016-04-10 22:23:37adminsetmessages: + msg8047
2016-01-28 01:00:35adminsetmessages: + msg7941
2016-01-28 01:00:35adminsetmessages: + msg7940
2015-09-15 00:00:00admincreate