[libcxx-commits] [PATCH] D97742: [C++23] [P1518R2] Better CTAD behavior for containers with allocators

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 3 14:29:59 PST 2021

zoecarver added inline comments.

Comment at: libcxx/include/deque:1318
     deque(const deque& __c);
-    deque(const deque& __c, const allocator_type& __a);
+    deque(const deque& __c, const typename __identity<allocator_type>::type& __a);
Quuxplusone wrote:
> zoecarver wrote:
> > Quuxplusone wrote:
> > > zoecarver wrote:
> > > > I //think// all the compilers we that support support templated type aliases. WDYT about making this `deque(const deque& __c, const __identity_t<allocator_type>& __a);`?
> > > Indeed, I'm 99.9% sure we can use alias templates, because of `_EnableIf`.
> > > But right now libc++ has no `__identity_t` alias. If we were going to add one, I think I'd lobby for it to be like `_Ident<T>`, by analogy with `_EnableIf<B>`, just to keep the boilerplate as short as possible. (Although `_EnableIf` has advantages in minimizing helper template instantiations, whereas this thing would not.)
> > `_Ident<T>` sounds good to me :)
> > 
> > I know this doesn't have compile-time benefit, but I think it will make the code a bit cleaner. Just a small thing.
> Posted D97862. I went with `__identity_t` after all, because there are some irreducible uses of `__identity` and I didn't want to have, like, `__identity<T>` and `_Ident<T>` with subtly different meanings. (Even if `_EnableIf` //is// precedent! ;))
And uses fewer characters ;)

  rG LLVM Github Monorepo



More information about the libcxx-commits mailing list