cmcstl2 icon indicating copy to clipboard operation
cmcstl2 copied to clipboard

view::generate isn't pipeable

Open cjdb opened this issue 6 years ago • 3 comments

All the examples are ill-formed.

#include <experimental/ranges/range>

namespace view {
   using namespace std::experimental::ranges::view;
   using namespace std::experimental::ranges::view::ext;
} // namespace view

int main()
{
    auto s1 = view::generate([]{ return 0; }) | view::take(0);
    auto s2 = view::generate([]{ return 0; }) | view::take_while([](auto&&){ return true; });
    auto s3 = view::generate([]{ return 0; }) | view::filter([](auto&&){ return true; });
}

cjdb avatar Feb 02 '19 13:02 cjdb

The diagnostic is a bit too ugly for GitHub's confined spaces (see Compiler Explorer).

I've seen this issue crop up when functions haven't been SFINAEd out correctly: perhaps this could be something similar.

cjdb avatar Feb 02 '19 13:02 cjdb

@cjdb: The code seems to be dancing around some gcc inconsistencies here. Using gcc-8.2.0 on OSX, the compilation fails without the -Wall flag, but succeeds with it. On Ubuntu gcc-8.1.0, it succeeds either way.

On Compiler Explorer: gcc-trunk: fails gcc-8.2: success (-Wall) gcc-8.2: success (without -Wall)

On OSX: gcc-8.2.0: success (-Wall) gcc-8.2.0 fails (without -Wall)

On Ubuntu: gcc-8.1.0: success (-Wall) gcc-8.1.0: success (without -Wall)

cheers, mark

melton1968 avatar Feb 12 '19 13:02 melton1968

Reduces to:

#include <stl2/view/generate.hpp>

int main() {
    auto r = __stl2::view::ext::generate([]{ return 0; });
    noexcept(__stl2::begin(r));
}

which nicely repros the "exception specification of begin depends on itself" issue on 8.2.

CaseyCarter avatar Feb 12 '19 18:02 CaseyCarter