[libcxx-commits] [PATCH] D132081: [libc++] Remove __deque_base
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 6 11:00:21 PDT 2022
philnik added a comment.
In D132081#3772577 <https://reviews.llvm.org/D132081#3772577>, @brooksmoses wrote:
> I'm seeing new compilation errors from the moved allocator `static_assert` in this patch.
>
> Reduced test case:
>
> #include <deque>
> #include <memory>
> BaseContainerTtemplate <typename T> struct CustomAllocator : public std::allocator<T> {};
> void foo() {std::deque<int, CustomAllocator<int>> bar;}
>
> Error:
>
> include/c++/v1/deque:974:3: error: static assertion failed due to requirement 'is_same<CustomAllocator<int>, std::allocator<int>>::value': rebinding an allocator to value_type should result in the original allocator
> static_assert(is_same<allocator_type, typename __rebind_alloc_helper<__alloc_traits, value_type>::type>::value,
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> test.cc:4:51: note: in instantiation of template class 'std::deque<int, CustomAllocator<int>>' requested here
> void foo() {std::deque<int, CustomAllocator<int>> bar;}
> ^
>
> Could you please investigate?
The `static_assert` wasn't moved, it was added. As the error message says, rebinding an allocator to the same type has to result in the same allocator. You have to add something like
template <class U>
struct rebind {
using other = allocator<U>;
};
to your allocator pre-C++20.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132081/new/
https://reviews.llvm.org/D132081
More information about the libcxx-commits
mailing list