ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.05k stars 437 forks source link

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

Open ytimenkov opened 3 years ago

ytimenkov commented 3 years ago

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?

marehr commented 3 years ago

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

marehr commented 3 years ago

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