Can I use to enter an alias into an array?

I am not sure that it was formulated correctly, because this is a bit strange situation. Basically, I found this code:

template<class T>
struct X { typedef T Type; };

template<class T>
struct X<const T[]> { typedef T Type[]; }

And I was in the process of changing typedefto use syntax like C ++ 11 syntax using, when I realized that this was not like the second example.

i.e. this is impossible to do:

template<class T>
struct X<const T[]> { using Type[] = T; }

Why is this? Is this “oversight” by the standard committee?

+2
source share
1 answer

The correct syntax is:

using Type = T[];

which defines what Typeis of type "array of unknown boundary T".

+4
source

Source: https://habr.com/ru/post/1679248/


All Articles