STL icon indicating copy to clipboard operation
STL copied to clipboard

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

Open hewillk opened this issue 2 years ago • 1 comments

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.

hewillk avatar Oct 19 '23 17:10 hewillk

To be even more pedantic, we should always use direct-non-list-initialization.

CaseyCarter avatar Oct 23 '23 23:10 CaseyCarter