-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Code cleanups #827
Merged
Merged
Code cleanups #827
Conversation
This file contains 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
Note that all of these are our types, not user-defined types. experimental/filesystem Use `path{}` and `file_status{}`. Drop unnecessary comments for `begin()` and `end()`. Return `{}` for `directory_iterator` and `recursive_directory_iterator` `end()`. (This is what Standard `<filesystem>` does.) filesystem Use `path{}`. memory Use `weak_ptr{}`. random Use `true_type{}`, `is_arithmetic<_Gen>{}`, and `is_signed<_Ty>{}`.
We conventionally qualify all non-`_Ugly` non-member function calls, even those with zero arguments (and therefore zero risk of ADL hijacking). However, many calls to `future_category()`, `generic_category()`, `iostream_category()`, and `system_category()` were missing `_STD`.
This has the same effect as `_Code = error_code();`, but with better throughput (avoiding `operator=` SFINAE) and increased consistency with Standard `<filesystem>`.
This is more efficient (because it avoids calling `system_category()`) and consistent with Standard `<filesystem>`. There's a slight semantic difference, which I believe is either irrelevant here or is an improvement: `error_code` equality considers both `value()` and `category()`, so an `error_code` with `value() == 0` but `generic_category()` would compare non-equal with `error_code()`, yet it would test as `false`. I believe that this is irrelevant because the `<experimental/filesystem>` machinery will never construct such an `error_code`.
The empty lines at the beginning of pair's verbose assignment operators were debatable, but I decided to remove them.
This was the only occurrence of a "convenient" using-directive in the entire STL's product code. (The others are doing necessary work, or working around compiler bugs.) While this was function-local and didn't create correctness issues, I felt that it was inconsistent with our usual conventions, and wasn't even saving significant verbosity. (Long ago, this was an enormously nested conditional expression, where the using-directive indeed helped. That was changed by Microsoft-internal MSVC-PR-182277, to the current chain of if-statements.)
CaseyCarter
approved these changes
May 13, 2020
CaseyCarter
reviewed
May 13, 2020
CaseyCarter
approved these changes
May 13, 2020
CaseyCarter
approved these changes
May 14, 2020
mnatsuhara
approved these changes
May 14, 2020
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.
<experimental/filesystem>
file_status{}
and{}
forpath
.begin()
andend()
.{}
fordirectory_iterator
andrecursive_directory_iterator
end()
. (This is what Standard<filesystem>
does.)<filesystem>
{}
forpath
.<memory>
weak_ptr{}
.<random>
true_type{}
,is_arithmetic<_Gen>{}
, andis_signed<_Ty>{}
._STD
qualification._Ugly
non-member function calls, even those with zero arguments (and therefore zero risk of ADL hijacking). However, many calls tofuture_category()
,generic_category()
,iostream_category()
, andsystem_category()
were missing_STD
._Code.clear()
._Code = error_code();
, but with better throughput (avoidingoperator=
SFINAE) and increased consistency with Standard<filesystem>
.if (_Code != error_code())
toif (_Code)
.system_category()
) and consistent with Standard<filesystem>
. There's a slight semantic difference, which I believe is either irrelevant here or is an improvement:error_code
equality considers bothvalue()
andcategory()
, so anerror_code
withvalue() == 0
butgeneric_category()
would compare non-equal witherror_code()
, yet it would test asfalse
. I believe that this is irrelevant because the<experimental/filesystem>
machinery will never construct such anerror_code
._Code != error_code()
to_Code
._Code == error_code()
to!_Code
.<regex>
.