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>: Improve implementation of recommended practices in views::cartesian_product #3839

Merged
merged 14 commits into from
Jul 14, 2023

Conversation

JMazurkiewicz
Copy link
Contributor

@JMazurkiewicz JMazurkiewicz commented Jun 29, 2023

In #3561 I've introduced _Compile_time_max_size template variable that detects ranges with max size known at compile time. Those types currently are:

  • const? std::array<T, N> (_Compile_time_max_size = N),
  • const? std::span<T, N> (_Compile_time_max_size = N),
  • const? ref_view<T> (_Compile_time_max_size = _Compile_time_max_size<T>),
  • const? owning_view<T> (_Compile_time_max_size = _Compile_time_max_size<T>).
  • Types with static constexpr size function, like empty_view (_Compile_time_max_size = 0), single_view (_Compile_time_max_size = 1).

(More about this approach: #3561, 'implementation details' section).

This PR expands influence of _Compile_time_max_size to all possible range adaptors and to C-style arrays.

@JMazurkiewicz JMazurkiewicz requested a review from a team as a code owner June 29, 2023 11:31
@StephanTLavavej StephanTLavavej added enhancement Something can be improved ranges C++20/23 ranges labels Jun 30, 2023
@strega-nil-ms strega-nil-ms self-assigned this Jun 30, 2023
@StephanTLavavej

This comment was marked as resolved.

stl/inc/ranges Show resolved Hide resolved
#if _HAS_CXX23
template <class _Rng, class _Fn, size_t _Nx>
inline constexpr auto _Compile_time_max_size<adjacent_transform_view<_Rng, _Fn, _Nx>> =
_Compile_time_max_size<adjacent_view<_Rng, _Nx>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

no change requested - this could be _Adjacent_view_compile_time_max_size<_Rng, _Nx>() to avoid the indirection.

@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 b32f3b4 into microsoft:main Jul 14, 2023
35 checks passed
@StephanTLavavej
Copy link
Member

Thanks for enhancing this metaprogramming! 📈 🚀 ✨

@JMazurkiewicz JMazurkiewicz deleted the compile-time-max-size branch July 14, 2023 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved ranges C++20/23 ranges
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants