C++ Logo

std-discussion

Advanced search

What's the usage of type_identity?

From: Akira Takahashi <faithandbrave_at_[hidden]>
Date: Fri, 18 Dec 2020 15:04:04 +0900
Hi,
I have a question.

P1021R3 Filling holes in Class Template Argument Deduction
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1021r3.html

P1814R0 Wording for Class Template Argument Deduction for Alias Templates
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1814r0.html

template <class T, class U>
struct C {
  C(T, U); // #1
};

template <class T, class U>
C(T, U) -> C<T, std::type_identity_t<U>>; #2 THIS

What's the usage of type_identity?
Why not directly use a constructor?

Thanks,
Akira

Received on 2020-12-18 00:04:17