Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't move construct semiregular from non-capturing lambda #986

Closed
JohelEGP opened this issue Jan 12, 2019 · 1 comment
Closed

Can't move construct semiregular from non-capturing lambda #986

JohelEGP opened this issue Jan 12, 2019 · 1 comment
Labels

Comments

@JohelEGP
Copy link
Contributor

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)}};
                                             ^~~~~~~~~~~~~~
@CaseyCarter
Copy link
Collaborator

CaseyCarter commented Jan 12, 2019

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.

CaseyCarter added a commit to CaseyCarter/range-v3 that referenced this issue Jan 12, 2019
Drive-by: parenthesize non-primary-expression in requires-clause

Fixes ericniebler#986.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants