Search code examples
c++aliasusing

Create multiple aliases with "using"


I have written a templated 2D-vector struct, XY<T>, and I want to make a number of aliases for it, so I write:

using XYf = XY<float>;
using XYd = XY<double>;
using XYld = XY<long double>;
using XYi = XY<signed int>;
using XYli = XY<long signed int>;
using XYs = XY<short signed int>;
using XYsb = XY<signed char>;

But I am wondering if it is possible to declare this in a similar way to how you can declare a number of variables of the same type:

float a, b, c, d;

Is it possible to do it in some other way, such as:

using 
    XYf = XY<float>,
    XYd = XY<double>,
    XYi = XY<int>;

Well, I've obvious tested that version, and it doesn't work, but I'm wondering if there any other alternatives to how one could declare a number of aliases to the same type with using.


Solution

  • There is no such way. A single type-aliasing using directive can only introduce a single new type.