Partial template instanciation

Viewed 61

If I have this two template classes:

template<int a, typename V>
class A {
};

template<template<int, typename> typename V>
class  B {
};

I can write something like B<A> a;. How can I achieve a similar thing for this two classes:

template<int a, typename V>
class A {
};

template<template<typename> typename V>
class  B {
};

I want to declare a variable like this B<A<1>> a;, but it says that A needs 2 parameters, which would be correct for an instance of A, but I only want to create a new template with a smaller number of parameters.

How can I achieve this?

1 Answers

You can't do this directly, but you can create a helper template using and pass it to B.

template <int N>
struct foo
{
    template <typename T>
    using type = A<N, T>;
};

B<foo<42>::type> x;
Related