Skip to content

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

Description

@cpplearner

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");
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improvedfixedSomething works now, yay!rangesC++20/23 ranges

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions