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

<ranges>: Poor error message when ranges::to cannot find a way to create the result #4562

Closed
cpplearner opened this issue Apr 4, 2024 · 0 comments · Fixed by #4608
Closed
Labels
enhancement Something can be improved fixed Something works now, yay! ranges C++20/23 ranges

Comments

@cpplearner
Copy link
Contributor

Currently, if ranges::to cannot create the result, the error message just says "the program is ill-formed per N4950 [range.utility.conv.to]/2.3".

STL/stl/inc/ranges

Line 10377 in be81252

static_assert(_Always_false<_Container>, "the program is ill-formed per N4950 [range.utility.conv.to]/2.3");

This doesn't help an average user to understand the problem.

It should be possible to give a more detailed message. What I have in mind:

if constexpr (_Ref_converts<_Rng, _Container>) {
    static_assert(false, "cannot find a way to create the result: "
                         "neither constructor call nor insertion at the end works");
} else {
    static_assert(
        false, "elements of the destination container must be "
               "implicitly convertible from elements of the source range");
}
@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Apr 10, 2024
@StephanTLavavej StephanTLavavej added the ranges C++20/23 ranges label Apr 20, 2024
@StephanTLavavej StephanTLavavej added the fixed Something works now, yay! label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved fixed Something works now, yay! ranges C++20/23 ranges
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants