[libcxx-commits] [PATCH] D97862: [libc++] Introduce __identity_t<T>

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 3 08:20:30 PST 2021


Quuxplusone created this revision.
Quuxplusone added reviewers: zoecarver, ldionne.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This is just a shorter synonym for `__identity<T>::type`.
Use it consistently throughout, where possible.

There is still some metaprogramming in <memory> and <variant>
where `__identity` is being used _without_ immediately calling
`::type` on it; but this is the unusual case, and it will become
even less usual as we start deliberately protecting certain types
against deduction (e.g. D97742 <https://reviews.llvm.org/D97742>).

(Btw, I've really looked at the instances in <memory> and I think they cannot trivially be adjusted to use `__identity_t`; it's using `__dependent_type<__identity<T>, Dummy>::type` and thus relying on the fact that `__identity<T>` is non-final even when `T` is final. I have not //really// looked at the instances in <variant>; I think it's using `__identity<T>` as an empty tag type for dispatch, similar to `in_place_type_t<T>`, but I'm not technically 100% sure.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97862

Files:
  libcxx/include/map
  libcxx/include/set
  libcxx/include/type_traits
  libcxx/include/unordered_map
  libcxx/include/unordered_set

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97862.327806.patch
Type: text/x-patch
Size: 7968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210303/3d99d41d/attachment.bin>


More information about the libcxx-commits mailing list