ericniebler/range-v3

Can't move construct semiregular from non-capturing lambda

JohelEGP opened this issue · 1 comments

Branch: v1.0-beta
The following extract fails to compile because the storage for the lambda couldn't be constructed.

std::string_view{} | ranges::view::split([](char c) { return true; });

[...]/build/clang/_deps/range-v3-src/include/range/v3/view/split.hpp:265: error: no viable conversion from typename std::remove_reference<(lambda at [...]/src/gfm.cpp:426:36) &>::type (aka (lambda at [...]/src/gfm.cpp:426:36)) to semiregular_t<(lambda at [...]/src/gfm.cpp:426:36)> (aka ranges::semiregular<(lambda at [...]/src/gfm.cpp:426:36)>)

                    predicate_pred<Rng, Fun>{std::move(fun)}};
                                             ^~~~~~~~~~~~~~

predicate_pred<Rng, Fun> is an aggregate with a single member of type semiregular_t<Fun>. predicate_pred<Rng, Fun>{std::move(fun)}}; attempts to copy-initialize that member from an rvalue Fun, which fails since semiregular's corresponding converting constructor is explicit.

The equivalent std::optional converting constructor is explicit(!is_convertible_v</**/>), so this is a bug.