[libcxx-commits] [PATCH] D133638: [libc++] static_assert that rebinding the allocator works as expected

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Oct 14 06:37:10 PDT 2022


philnik added a comment.

In D133638#3858259 <https://reviews.llvm.org/D133638#3858259>, @bgraur wrote:

> In D133638#3850477 <https://reviews.llvm.org/D133638#3850477>, @philnik wrote:
>
>> @rupprecht I don't think there is a bug here. You allocator isn't conforming. The difference between your example and the standard example is that the standard example is a template, which can be rebound by default (see https://eel.is/c++draft/allocator.requirements#general-18). This is actually one of the bugs this patch is trying to catch.
>
> I have a followup question regarding this: the statement you linked (https://eel.is/c++draft/allocator.requirements#general-18) says that for `SomeAllocator<T, Args>` if "`Allocator` does not supply a rebind member template, the standard allocator_­traits template uses SomeAllocator<U, Args> in place of Allocator​::​rebind<U>​::​other by default."
>
> With this change the statement stands for a `template <class T, class Y> class FooAllocator {.. }` (https://godbolt.org/z/4PjeedeP4) and doesn't for a `template <class T, int X> class FooAllocator {.. }` (https://godbolt.org/z/j9sxo65vc).
> In the latter case we still look for the `rebind<_Up>::other` member template.
>
> Is that intended?

Yes. I don't think there is a way to generally rebind classes with NTTPs. This has to be special-cased for these allocators.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133638/new/

https://reviews.llvm.org/D133638



More information about the libcxx-commits mailing list