问题
I'm not sure I've worded this properly since this is a bit of an odd situation. Basically I've found some code like this:
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 the typedef
s to use the C++11 using
type-alias syntax when I realised this doesn't seem to work for the second example.
i.e. it isn't possible to do:
template<class T>
struct X<const T[]> { using Type[] = T; }
Why is this? Is this an 'oversight' by the standards comittee?
回答1:
The right syntax is:
using Type = T[];
which defines that Type
has the type "array of unknown bound of T
".
来源:https://stackoverflow.com/questions/43013243/can-using-be-used-to-type-alias-an-array