Cleanups: Consistently comment enable_if_t definitions#3539
Merged
StephanTLavavej merged 4 commits intomicrosoft:mainfrom Mar 7, 2023
Merged
Cleanups: Consistently comment enable_if_t definitions#3539StephanTLavavej merged 4 commits intomicrosoft:mainfrom
enable_if_t definitions#3539StephanTLavavej merged 4 commits intomicrosoft:mainfrom
Conversation
There are no other declarations.
…untl_zero()`, and `swap()` for arrays.
For C++17, follow the convention where the declaration is ` = 0` and the definition is `/* = 0 */`. For C++14, we want to emphasize the purpose of the second template parameter, so the declaration is `int _Enabled = 0` and the definition is `int _Enabled /* = 0 */`.
CaseyCarter
approved these changes
Mar 5, 2023
Member
Author
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For C++17's parallel algorithms, where we separately declare and define many of them, we developed a convention where the declaration is
= 0and the definition is/* = 0 */. This is a reminder that while the default template argument can't be repeated, we haven't simply forgotten it:STL/stl/inc/algorithm
Lines 1124 to 1125 in 994f941
STL/stl/inc/execution
Lines 1119 to 1120 in 994f941
Thanks to Michael Grier for noticing that we've accumulated inconsistency elsewhere, with relics of an older convention where we'd name the template parameter in the definition
_Enabled. That older convention was less clear and doesn't really provide new information (as we're already usingenable_if_t)._Enabled = 0to= 0forcountr_one()and_Popcount()._Enabledto/* = 0 */forduration_cast(),rotr(),countl_zero(), andswap()for arrays.swap(_Ty&, _Ty&).= 0and the definition is/* = 0 */.int _Enabled = 0and the definition isint _Enabled /* = 0 */./* = 0 */totuple's ctors anduses_allocator_construction_args().After this cleanup, the only remaining uses of
_Enabledin product code are in other contexts. I've audited all occurrences whereenable_if_tappears in separate declarations and definitions, including through helper typedefs, so this cleanup should be fairly exhaustive.