Skip to content

Cleanups 3: Simple changes - #2675

Merged
Stephan T. Lavavej (StephanTLavavej) merged 11 commits into
microsoft:mainfrom
StephanTLavavej:cleanups-3-simple
May 1, 2022
Merged

Stephan T. Lavavej (StephanTLavavej) merged 11 commits into
microsoft:mainfrom
StephanTLavavej:cleanups-3-simple

Conversation

@StephanTLavavej

Copy link
Copy Markdown
Member
  • : Fuse #if !_HAS_CXX20 sections.
  • : wbuffer_convert and wstring_convert were using implicit private:.
  • : scoped_allocator_adaptor was using implicit private:.
  • : Remove repeated protected:.
  • : Mark _Small_object_num_ptrs as _INLINE_VAR.
  • : Mark constants as _INLINE_VAR.
    • We conventionally mark constants as _INLINE_VAR (or inline in C++17+) even when there's no real risk of odr-using them.
  • : Use _STL_INTERNAL_STATIC_ASSERT for _Big_allocation_alignment.
    • This is a constant that we control, so there's no reason to evaluate these static_asserts for user code.
  • : Mark _Future_error_map as _NODISCARD.
  • : Extract _Array_const_iterator members that are IDL-independent.
    • This reduces repetition, and will make it easier to move n + iter to be a hidden friend (currently blocked by a compiler bug until 17.3 Preview 2).
  • Avoid various uses of auto*.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  • Should this also change VSO_0{7}_initialize_everything:test_weak_ptr_construction:all_zero to remove auto*?

@strega-nil-ms nicole mazzuca (strega-nil-ms) removed their assignment Apr 28, 2022
@CaseyCarter Casey Carter (CaseyCarter) removed their assignment Apr 28, 2022
@StephanTLavavej

Copy link
Copy Markdown
Member Author

nicole mazzuca (@strega-nil-ms) - good question. This is creating a templated lambda:

const auto all_zero = [](const auto* const ptr) {
const auto first = reinterpret_cast<const char*>(ptr);
const auto last = reinterpret_cast<const char*>(ptr + 1);
return all_of(first, last, [](const auto x) { return x == 0; });
};

I initially hesitated to change this because it seemed a larger change than the rest, but you're right, eliminating the last occurrence of auto* seems worth it. It's OK if ptr ends up being a const pointer to modifiable T (I didn't look into the usage deeply enough to see whether that actually happens), as we add constness when reinterpreting to const char* and don't otherwise interact with ptr.

@StephanTLavavej

Copy link
Copy Markdown
Member Author

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

@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) merged commit b9505b9 into microsoft:main May 1, 2022
@StephanTLavavej
Stephan T. Lavavej (StephanTLavavej) deleted the cleanups-3-simple branch May 1, 2022 10:36
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.

3 participants