]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
common: replace BitVector::NoInitAllocator with wrapper struct 45179/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 15 Feb 2022 23:27:10 +0000 (18:27 -0500)
committerDeepika Upadhyay <dupadhya@redhat.com>
Sat, 26 Feb 2022 18:32:45 +0000 (00:02 +0530)
commit0468098d26012ef0120286d5b609a0876ced2958
tree9c7739489ceb667874fad1aaa749ce71305cec30
parentc42a10239a4c0d70677bb99dfd0fe2d910016c8a
common: replace BitVector::NoInitAllocator with wrapper struct

in c++20, the deprecated `struct std::allocator<T>::rebind` template was
removed, so `BitVector` no longer compiles. without a `rebind` to
inherit, `std::allocator_traits<NoInitAllocator>::rebind_alloc<U>` was
looking for `NoInitAllocator<U>`, but it isn't a template class

further investigation found that in c++17, `vector<__u32, NoInitAllocator>`
was rebinding this `NoInitAllocator` to `std::allocator<__u32>` and
preventing the no-init optimization from taking effect

instead of messing with the allocator to avoid zero-initialization, wrap
each __u32 in a struct whose constructor does not initialize the value

Fixes: https://tracker.ceph.com/issues/54279
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 4f0ad8aab6b21a1fd57a7c1630d298e31b5d9bb6)
src/common/bit_vector.hpp