In order to avoid code repetition, I need to do something like this (in my real code I have much more complex types similar to T1
and T2
):
template <class T1, class T2>
struct A
{};
template <class T1, class T2>
struct B
{};
template <class X>
struct C
{
using p1 = int;
using p2 = char;
using some = X<p1, p2>;
};
int main()
{
C<A> o1; // must produce C<A<int,char> >
C<B> o2; // must produce C<B<int,char> >
}
Your class C
needs to use a template template parameter in order to accept A
and B
as input to its own template so it can then pass parameters to them, eg:
template <template<typename T1, typename T2> class X>
struct C
{
using p1 = int;
using p2 = char;
using some = X<p1, p2>;
};
Now you can do this:
C<A> o1; // produce C<A<int,char> >
C<B> o2; // produce C<B<int,char> >
See a demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With