Initialise template class with different template parameters

  alias, c++, templates

I’m trying to create the same class from a class template with different template parameters.

Let’s say I create a custom type A which is create via a class template

typename <int i1, int i2>
class A { }

now I have a second class template B that takes a A<x,y> as its template parameter

template <typename A_T>
class B { }

I could define alias template to also allow

template <int i1, int i2>
using BD = B<A<i1, i2>>;

My question is is there any way of designing this such that the template name would be the same for the user in bother cases? I.e. such that a user could do

typedef A<1,2> A_t;
B<A_t> b1;

B<1,2> b2; // Rather than BD<1,2>;

Any help is much appreciated.

Source: Windows Questions C++

LEAVE A COMMENT