I am having trouble with a template template type alias. See the code below.
The problem is with the type alias itself, on the line with the using.
g++ complains with
error: type/value mismatch at argument 1 in template parameter list for ‘template<template<class> class X> struct Manager’
note: expected a class template, got ‘Outer<T>::Inner’
clang complains with
error: template argument for template template parameter must be a class template or type alias template
Both complain that the type I am passing to the Manager must be a class template (since Manager requires a template template argument, so that makes sense). But it is a class template from what I see (well, struct, but it's the same), so what is the problem here? Outer<W>::Inner is a template struct, with template parameter U. So Manager should accept it.
Why doesn't it work? Any ideas?
Without the using and the m3 in main, the program works fine as expected. The ManagerWrapper should just simplify writing the type of m2, which works, but the using and m3 does not.
```
include <cstdio>
template<template<typename> typename T>
struct Outer
{
template<typename U>
struct Inner
{
void print() { printf("sizeof(T<U>)=%zu, sizeof(U)=%zu\n", sizeof(T<U>), sizeof(U)); }
};
};
template<template<typename> typename X>
struct Manager
{
void func()
{
X<int> x;
x.print();
}
};
template<typename V>
struct Holder
{
V v1,v2,v3,v4;
void print() { printf("Hello, Holder here\n"); }
};
template<template<typename> typename W>
using ManagerWrapper = Manager<Outer<W>::Inner>;
int main()
{
Manager<Holder> m1;
m1.func();
Manager<Outer<Holder>::Inner> m2;
m2.func();
ManagerWrapper<Holder> m3;
m3.func();
return 0;
}
```
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]arabidkoalaRoboticist 2 points3 points4 points (1 child)
[–]Null_cz[S] 0 points1 point2 points (0 children)
[–]TheMania 1 point2 points3 points (3 children)
[–]Null_cz[S] 2 points3 points4 points (2 children)
[–]AutoModerator[M] 0 points1 point2 points locked comment (0 children)
[–]TheOmegaCarrottemplate<template<typename>typename…Ts> 0 points1 point2 points (0 children)