range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

Why does std::filesystem::directory_iterator not satisfy borrowed_range concept like std::basic_string_view?

Open ytimenkov opened this issue 5 years ago • 2 comments

I've started playing with with ranges and C++20 and came to the similar problem as in #1400 But I did:

namespace ranges
{
template <>
inline constexpr bool enable_borrowed_range<std::filesystem::directory_iterator> = true;
}

Which allows me to write and compile code like this: (gcc 10.2, Linux):

fs::directory_iterator{"/home"} |
           views::filter([](fs::directory_entry const& e) {
               return e.is_directory();
           });

Why this is not enabled by default?

ytimenkov avatar Oct 29 '20 13:10 ytimenkov

Maybe related https://cplusplus.github.io/LWG/issue3480.

marehr avatar Dec 08 '20 21:12 marehr

@BRevzin Sorry that I ping you, but what are your thoughts on this?

marehr avatar Dec 08 '20 21:12 marehr