Skip to content

<algorithm>: iter_value_t<I> should always use direct-initialization #4109

Description

@hewillk

When a temporary iter_value_t needs to be constructed, MSVC-STL usually uses copy initialization through iter_value_t<I> val = *it; or iter_value_t<I> val = ranges::iter_move(it);.
However, this is not exposed in the standard concept, both indirectly_movable_storable and indirectly_copyable_storable use constructible_from instead of convertible_to, which does not guarantee that copy-initialization is valid when explicit falls from the sky.
I believe it's extremely pedantic to show an example like this, and I'm not sure it's worth submitting an LWG since Cpp17InputIterator ([iterator.cpp17]) seems to guarantee copy-initialization.
Although based on the current wording we obviously should use direct-initialization.

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

    bugSomething isn't workingfixedSomething 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