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

Implement LWG-3785 ranges::to is over-constrained on the destination type being a range #3319

Merged
merged 2 commits into from Jan 12, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

Fixes #3227.

I failed to figure out how to "convert a range of expected<T, E> to expected<vector<T>, E>" with ranges::to, so I just added some trivial test cases...

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner January 1, 2023 15:50
@CaseyCarter CaseyCarter added LWG Library Working Group issue ranges C++20/23 ranges labels Jan 2, 2023
@CaseyCarter CaseyCarter added this to Initial Review in Code Reviews via automation Jan 2, 2023
@@ -7668,7 +7668,8 @@ namespace ranges {
// clang-format on

template <class _Rng, class _Container>
concept _Ref_converts = convertible_to<range_reference_t<_Rng>, range_value_t<_Container>>;
concept _Ref_converts =
(!input_range<_Container>) || convertible_to<range_reference_t<_Rng>, range_value_t<_Container>>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For other reviewers: these parentheses are needed only to avoid clang-format damage.

@CaseyCarter CaseyCarter moved this from Initial Review to Final Review in Code Reviews Jan 2, 2023
@strega-nil-ms strega-nil-ms moved this from Final Review to Ready To Merge in Code Reviews Jan 3, 2023
@hewillk
Copy link
Contributor

hewillk commented Jan 8, 2023

I failed to figure out how to "convert a range of expected<T, E> to expected<vector<T>, E>" with ranges::to, so I just added some trivial test cases...

cc @brevzin

@brevzin
Copy link

brevzin commented Jan 8, 2023

I failed to figure out how to "convert a range of expected<T, E> to expected<vector<T>, E>" with ranges::to, so I just added some trivial test cases...

cc @brevzin

Somebody would need to propose a new expected(from_range_t, R&&) constructor that does this, it's good that it doesn't work out of the box. The goal was simply to be able to support that kind of conversion for types that want to opt in to it.

And yeah, we should add that constructor (but... not in this PR of course).

@StephanTLavavej StephanTLavavej self-assigned this Jan 11, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit a71aa52 into microsoft:main Jan 12, 2023
Code Reviews automation moved this from Ready To Merge to Done Jan 12, 2023
@StephanTLavavej
Copy link
Member

Thanks for changing the STL to be more conformant and useful! 😹 🤪 🚀

@frederick-vs-ja frederick-vs-ja deleted the lwg-3785 branch January 12, 2023 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue ranges C++20/23 ranges
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

LWG-3785 ranges::to is over-constrained on the destination type being a range
6 participants