https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95100

            Bug ID: 95100
           Summary: <ranges> xxx_view adaptors don't work with pipeline
                    operator
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rhalbersma at gmail dot com
  Target Milestone: ---

Combining the std::ranges::xxx_view adaptors with the pipeline operator does
not compile, in contrast to the supposedly expression equivalent
std::ranges:views::xxx 

#include <iostream>
#include <ranges> 
#include <vector>

int main() {
    auto v = std::vector { 1, 2, 3, 4, 5, 6 };

    // OK
    for (auto elem : std::ranges::views::reverse(v)) {
        std::cout << elem << ',';
    }

    // OK    
    for (auto elem : std::ranges::reverse_view(v)) {
        std::cout << elem << ',';
    }

    // OK
    for (auto elem : v | std::ranges::views::reverse) {
        std::cout << elem << ',';
    }

    // error: missing template arguments before ')' token
    for (auto elem : v | std::ranges::reverse_view) {
        std::cout << elem << ',';
    }

    // OK
    for (auto elem : v | std::ranges::views::transform([](auto e) { return e +
1; })) {
        std::cout << elem << ',';
    }    

    // error: class template argument deduction failed:
    for (auto elem : v | std::ranges::transform_view([](auto e) { return e + 1;
})) {
        std::cout << elem << ',';
    }
}

See online example on Wandbox here:
https://wandbox.org/permlink/E6ScFmm8DdmkFo74

Tested this also for drop_view, take_view, filter_view etc., with similar
results (not shown for brevity in the code snippet).

Reply via email to