std::vector<bool> code cleanup fixes optimizations
Jonathan Wakely
jwakely@redhat.com
Fri Jul 31 21:47:37 GMT 2020
On 31/07/20 23:03 +0200, François Dumont via Libstdc++ wrote:
>On 17/07/20 12:36 pm, Jonathan Wakely wrote:
>>On 16/12/19 08:18 +0100, François Dumont wrote:
>>>diff --git
>>>a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/swap.cc
>>>b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/swap.cc
>>>index de441426532..745fdc85cf6 100644
>>>--- a/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/swap.cc
>>>+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/allocator/swap.cc
>>>@@ -28,19 +28,17 @@ namespace __gnu_test
>>>Â // It is undefined behaviour to swap() containers with unequal
>>>allocators
>>>Â // if the allocator doesn't propagate, so ensure the allocators
>>>compare
>>>Â // equal, while still being able to test propagation via
>>>get_personality().
>>>+Â template<typename Type>
>>>Â Â Â bool
>>>-Â operator==(const propagating_allocator<T, false>&,
>>>-Â Â Â Â Â Â Â Â const propagating_allocator<T, false>&)
>>>-Â {
>>>-Â Â Â return true;
>>>-Â }
>>>+Â Â Â operator==(const propagating_allocator<Type, false>&,
>>>+Â Â Â Â Â Â Â Â Â Â const propagating_allocator<Type, false>&)
>>>+Â Â Â { return true; }
>>>
>>>+Â template<typename Type>
>>>Â Â Â bool
>>>-Â operator!=(const propagating_allocator<T, false>&,
>>>-Â Â Â Â Â Â Â Â const propagating_allocator<T, false>&)
>>>-Â {
>>>-Â Â Â return false;
>>>-Â }
>>>+Â Â Â operator!=(const propagating_allocator<Type, false>&,
>>>+Â Â Â Â Â Â Â Â Â Â const propagating_allocator<Type, false>&)
>>>+Â Â Â { return false; }
>>
>>Why does this test need to be adapted?
>>
>Because I replicate and adapt the static assertion from the main
>vector implementation which is:
>
>#if __cplusplus >= 201103L
>__glibcxx_assert(_Bit_alloc_traits::propagate_on_container_swap::value
>Â Â Â Â Â Â Â Â Â Â || _M_get_Bit_allocator() == __x._M_get_Bit_allocator());
>#endif
>
>in the case of vector<bool> the compared allocators are not
>propagating_allocator<bool, false> but propagating_allocator<unsigned
>long, false>.
Ah yes, of course. Thanks.
>Building with __glibcxx_assert was showing this.
>
>François
>
More information about the Gcc-patches
mailing list