Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@StephanTLavavej
Copy link
Member

We conventionally avoid the pattern auto variable = Type{args}; because it is strictly more complicated than Type variable{args};. Following this convention reserves auto for the cases where it's doing real work to deduce a type.

We've accumulated a few cases which I'm cleaning up here. (There are a few more cases which I am reluctantly not changing, because auto results in code lining up nicely. I thought about it, though.)

In P2321R2_views_zip, I'm also performing some renames. We can name the parameters single_element_container and three_element_container, as that's relevant to the caller. Then we can rename the local copy to just writable, which avoids wrapping lines.

In <__msvc_int128.hpp>, I'm using static_cast. MSVC emits a signed/unsigned warning if we attempt to directly initialize _Int_max (possibly because numeric_limits::max() is constexpr but not consteval). Since we're intentionally changing the type from int to size_t, it seems stylistically best to emphasize this with a static_cast anyways.

Name the parameters single_element_container and three_element_container,
as that's relevant to the caller. Then we can rename the local copy to
just `writable`, which avoids wrapping lines.
MSVC emits a probably-unjustified signed/unsigned warning if we attempt
to directly initialize _Int_max. Since we're intentionally changing the
type from int to size_t, it seems stylistically best to emphasize this
with a static_cast anyways.
@StephanTLavavej StephanTLavavej added enhancement Something can be improved ranges C++20/23 ranges labels Mar 3, 2023
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner March 3, 2023 20:34
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

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

I still prefer almost always auto in a lot of these cases, but I know that's not the style of the standard library, so approve.

@StephanTLavavej StephanTLavavej self-assigned this Mar 7, 2023
@StephanTLavavej
Copy link
Member Author

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

@StephanTLavavej StephanTLavavej merged commit e7aa390 into microsoft:main Mar 7, 2023
@StephanTLavavej StephanTLavavej deleted the stl-cleanups-almost-never-auto branch March 7, 2023 19:43
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.

2 participants