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

ranges::to isn't a range adaptor closure object?

Open marehr opened this issue 3 years ago • 0 comments

Hi! This is more a question than a bug report.

I thought that range adaptor closure object, so a range adaptor that already bound it's possible arguments, allows the following syntax:

#include <range/v3/range/conversion.hpp>
#include <list>
#include <vector>

int main()
{
    std::list<int> list{1, 2, 3};
    // directly
    std::vector v1 = ranges::to<std::vector>(list);
    std::vector v2 = list | ranges::to<std::vector>;
    
    // as object
    auto adaptor = ranges::to<std::vector>;
    std::vector v3 = list | adaptor;
    std::vector v4 = adaptor(list); // does not compile
}

https://godbolt.org/z/Eb9Wen

Thank you!

marehr avatar Mar 09 '21 19:03 marehr