type_identity_t<To[]> is used here to satisfy an arbitrary restriction in the C++ language grammar.
The problem is that you can't make temporary arrays with a syntax like
|
T[]{ t1, t2, t3 }; // wrong
|
But you can get away with it when you spell
T[] in a different way:
1 2
|
using my_array = T[];
my_array{ t1, t2, t3 }; // ok
|
Incidentally
|
std::type_identity_t<T[]>{ t1, t2, t3 }; // ok
|
works too.
More specifically, the intent is to use [expr.type.conv] to construct an object whose type is
To[]. Ideally one could simply write
To[]{ std::forward<From>(x) } but that doesn't work because grammatically
To[] is neither a
typedef-name nor a
simple-type-specifier as the standard requires.
The workaround relies on that
type_identity_t<To[]> is the same type as
To[] but grammatically it is a
typedef-name and so the compiler accepts it.
https://eel.is/c++draft/expr.type.conv
See an equivalent trick used here:
https://cplusplus.com/forum/general/207656/#msg979820
Where the type alias
left_to_right is needed to satisfy the compiler for the same reason.