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

Implement LWG-3778 vector<bool> missing exception specifications #3332

Merged
merged 5 commits into from Jan 12, 2023

Conversation

frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Jan 8, 2023

Fixes #3226.

Notes:

  • The default constructor of vector<bool, _Alloc> need to default-construct an _Alloc instead of _Alvbase in order to implement the required exception specification. I think this is not related to allocator propagation and thus possibly not covered by LWG-3267.
    • Edit: I have to change the test P1004R2_constexpr_vector_bool due to this. Not sure whether such change is right now...
  • The constructor of _Vb_val from an allocator is always noexcept, so I changed the superfluous conditional noexcept to unconditional one.
  • The constructor of vector<bool, _Alloc> from (vector&&, const _Identity_t<_Alloc>&) is not noexcept in the current working draft, so I added // strengthened.
  • Exception specification of the move assignment operator of vector<bool, _Alloc> detect the properties of _Alvbase, which is consistent with other containers that need allocator rebinding.
    • I've mailed LWG chair to propose a more complete resolution of LWG-3267 (said in LWG-3778 vector<bool> missing exception specifications #3226 (comment)), which would be able to resolve the divergence between standard requirements and actual implementations.
    • The old exception specification is meaningless, since _Vb_val is not even move-assignable - the explicitly declared move constructor make the move assignment operator not declared, and the copy assignment operator implicitly deleted.
  • As small driven-by changes, references to the working draft are updated to refer to WG21-N4928.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner January 8, 2023 14:44
@CaseyCarter CaseyCarter added the LWG Library Working Group issue label Jan 9, 2023
@CaseyCarter CaseyCarter added this to Initial Review in Code Reviews via automation Jan 9, 2023
Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

One comment nit that I'll apply. (Oops - I missed "approve".)

stl/inc/vector Outdated Show resolved Hide resolved
@@ -2931,7 +2926,8 @@ public:
this->_Swap_proxy_and_iterators(_Right);
}

_CONSTEXPR20 vector& operator=(vector&& _Right) noexcept(is_nothrow_move_assignable_v<_Mybase>) {
_CONSTEXPR20 vector& operator=(vector&& _Right) noexcept(
_Choose_pocma_v<_Alvbase> != _Pocma_values::_No_propagate_allocators) {
if (this == _STD addressof(_Right)) {
return *this;
}
Copy link
Member

Choose a reason for hiding this comment

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

For other reviewers: vector<bool>::swap is already unconditionally noexcept with a strengthened comment in our implementation. We were previously strengthening from nothing to unconditional, after LWG-3778 we're strengthening from conditional to unconditional because we still aren't interested in throwing on precondition violation. (No change requested.)

@CaseyCarter CaseyCarter moved this from Initial Review to Final Review in Code Reviews Jan 9, 2023
@StephanTLavavej StephanTLavavej moved this from Final Review to Ready To Merge in Code Reviews Jan 11, 2023
@StephanTLavavej StephanTLavavej self-assigned this Jan 11, 2023
@StephanTLavavej
Copy link
Member

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

@StephanTLavavej StephanTLavavej merged commit ed9a3a0 into microsoft:main Jan 12, 2023
Code Reviews automation moved this from Ready To Merge to Done Jan 12, 2023
@StephanTLavavej
Copy link
Member

Thanks for implementing this LWG issue resolution in everyone's favorite partial specialization! 😻 👻 ✅

@frederick-vs-ja frederick-vs-ja deleted the lwg-3778 branch January 12, 2023 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LWG Library Working Group issue
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

LWG-3778 vector<bool> missing exception specifications
3 participants