Created on 2014-01-20.00:00:00 last changed 90 months ago
Proposed resolution:
Change 6 [fs.filesystem.synopsis]:
class directory_iterator; // enable directory_iterator range-based for statementsconstdirectory_iterator&begin(constdirectory_iterator&iter) noexcept; directory_iterator end(const directory_iterator&) noexcept; class recursive_directory_iterator; // enable recursive_directory_iterator range-based for statementsconstrecursive_directory_iterator&begin(constrecursive_directory_iterator&iter) noexcept; recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
Change 13.2 [directory_iterator.nonmembers]:
These functions enable use of directory_iterator
with C++11
range-based for statements.
constdirectory_iterator&begin(constdirectory_iterator&iter) noexcept;
Returns:
iter
.
directory_iterator end(const directory_iterator&) noexcept;
Returns:
directory_iterator()
.
Change 14.2 [rec.dir.itr.nonmembers]:
These functions enable use of recursive_directory_iterator
with C++11 range-based for statements.
constrecursive_directory_iterator&begin(constrecursive_directory_iterator&iter) noexcept;
Returns:
iter
.
recursive_directory_iterator end(const recursive_directory_iterator&) noexcept;
Returns:
recursive_directory_iterator()
.
[ 2014-02-13 LWG/SG-3 Issaquah: Proposed wording accepted. ]
[ 2014-02-11 Issaquah: Change begin() argument and return to pass-by-value. See wiki notes for rationale. Beman to provide wording for review next meeting. ]
[ 2014-02-08: Daniel responds to Beman ]
The difference in return types becomes relevant, when testing whether e.g. directory_iterator would satisfy the Traversable requirements as currently specified in N3763. Expressed in code form these requirements impose that the following assertion holds:
static_assert(std::is_same< decltype(std::range_begin(std::declval<directory_iterator>())), decltype(std::range_end(std::declval<directory_iterator>())) >::value, "No Traversable type");
Both directory_iterator and recursive_directory_iterator won't satisfy this requirement currently.
Addresses: filesys.ts
It is unclear why the range-for support functions (begin()/end()) for directory_iterator and recursive_directory_iterator return different types for begin() and end(), namely that begin() returns a reference to const and end() returns a value.
[2014-02-07: Beman Dawes provides comments from the Boost implementation:]
// begin() and end() are only used by a range-based for statement in the context of // auto - thus the top-level const is stripped - so returning const is harmless and // emphasizes begin() is just a pass through.
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:10:41 | admin | set | status: wp -> open |
2016-01-28 01:00:35 | admin | set | messages: + msg7725 |
2016-01-28 01:00:35 | admin | set | messages: + msg7724 |
2016-01-28 01:00:35 | admin | set | messages: + msg7723 |
2016-01-28 01:00:35 | admin | set | messages: + msg7722 |
2014-01-20 00:00:00 | admin | create |