Creating alias for concrete class template

We can create alias for class template by defining template type as follows,

 
template <typename T, typename U>
struct Collection
{
    T a;
    U b;
};
 
int main(int argc, char const *argv[])
{
    using IntCollection = Collection<int, int>;
    IntCollection c1{1, 2};
    return 0;
}

We can use IntCollection for Collection<int, int>.

Creating alias for class template itself

We can also create alias for a class template where we can provide some template type or not all as shown below,

template <typename T, typename U>
using Pair = Collection<T, U>;
 
template <typename T>
using IntPair = Collection<T, int>;

Pair can be used in the place of Collection where we need to provide both T and U template types. We can use it same as Collection as shown below,

Pair<int, int> p2{1, 2};
Pair p2{1, 2}; // CTAD works for alias as well.

IntPair can then be used as,

IntPair<float> p3{1.4, 3};
IntPair p4{1.4, 3}; // CTAD works

References

  1. https://www.learncpp.com/cpp-tutorial/alias-templates/