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

Various header cleanups #2802

Merged
merged 9 commits into from
Jun 20, 2022

Conversation

StephanTLavavej
Copy link
Member

  • <deque>, <forward_list>, <list>: Use nullptr instead of _Mapptr() and _Nodeptr().
    • At first, I was going to change these empty parens to empty braces for consistency with our modern conventions (braces make it clear when we're constructing a temporary instead of calling a function), but nullptr is even clearer.
    • This is guaranteed to work because they're "nullable pointers", and we're already using nullptr with these types:
      _Right_data._Map = nullptr;

      _Ptr->_Next = nullptr;

      _Ptr->_Prev = nullptr;
  • <array>, <tuple>: We don't need return after calling _Left.swap(_Right);.
  • <chrono>, <complex>, <format>: Use direct-init instead of Type var = Type{init}; which repeats the Type unnecessarily.
  • Several headers: Detach comments.
    • As usual, this isn't attempting to be comprehensive. I just noticed a few cases of ugly wrapping (including when function parameters are unnecessarily wrapped).
  • <memory_resource>:
    • Use centralized _STL_INTERNAL_STATIC_ASSERTs instead of user-visible static_asserts before every static_cast. (This is internal machinery, so we're just checking our own work here. I believe that this code may have predated the introduction of _STL_INTERNAL_STATIC_ASSERT.)
    • Also slightly update the _Intrusive_list comment for consistency with _Intrusive_stack.
    • In _Remove(), we don't need addressof() for raw pointers.
    • Rename _Foo (a meaningless name, which we conventionally avoid, especially in product code) to _Pnext (which is used in similar loops, and is actually somewhat descriptive here - except at the very beginning, it is pointing to a _Next).
  • <experimental/filesystem>: Drop // TRANSITION, ABI, #if 0 code.
    • IIRC, attempting to use _Path_cvt<value_type, char32_t> resulted in compiler errors, which we had hopes of someday fixing, or which perhaps were actually fixed by the codecvt_ids overhaul. In any event, there is no reason to attempt to enable these functions now. In vNext, we will simply eradicate <experimental/filesystem>.
  • Several headers: Construct temporary strings with braces.
    • Note that string_type(1, _FS_PREF) cannot be changed, as that would attempt to construct a sequence of 2 characters (guess how I found out):
      return path(string_type(1, _FS_PREF));

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Jun 17, 2022
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner June 17, 2022 04:54
@StephanTLavavej StephanTLavavej self-assigned this Jun 19, 2022
@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 d047fb3 into microsoft:main Jun 20, 2022
@StephanTLavavej StephanTLavavej deleted the various-inc-cleanups branch June 20, 2022 00:42
fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
  翻译: