lewissbaker / generator

Reference implementation of std::generator proposal
Boost Software License 1.0
25 stars 7 forks source link

Change std::ranges::elements_of() to be a function instead of a type used with CTAD #2

Closed lewissbaker closed 3 years ago

lewissbaker commented 3 years ago

The current implementation defines std::ranges::elements_of<Range> using CTAD to allow use like a function inside co_yield std::ranges::elements_of(someRange) expressions.

This choice, however, makes it difficult to later add overloads of std::ranges::elements_of() that might take additional arguments. e.g. an allocator if we wanted to allow overriding the allocator to be used for the implicit coroutine in some co_yield std::ranges::elements_of(range, alloc); expressions.

We should change elements_of() to be a function that returns the type elements_of_t<Range> instead of being a type to be used with CTAD to keep open this evolutionary pathway for the API.

cor3ntin commented 3 years ago

I don't necessarily think we should do that without running it through LEWG, especially as we have the allocator now. Well, tbh, I struggle being sympathetic with abi-motivated designs even if i know it will come back to haunt us. So, maybe you are right?

lewissbaker commented 3 years ago

Closing as wont-fix for now as CTAD is now viable with the extra template parameter added to elements_of.