#include <iostream>
template <typename T>
class A
{
public:
template <typename U>
A() {
std::cout << sizeof(T) << ' ' << sizeof(U) << std::endl;
}
};
int main() {
A<float> a(A<float>::A<int>());
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPHR5cGVuYW1lIFQ+CmNsYXNzIEEKewpwdWJsaWM6Cgl0ZW1wbGF0ZSA8dHlwZW5hbWUgVT4KCUEoKSB7CgkJc3RkOjpjb3V0IDw8IHNpemVvZihUKSA8PCAnICcgPDwgc2l6ZW9mKFUpIDw8IHN0ZDo6ZW5kbDsKCX0KfTsKCmludCBtYWluKCkgewoJQTxmbG9hdD4gYShBPGZsb2F0Pjo6QTxpbnQ+KCkpOwoJcmV0dXJuIDA7Cn0=
prog.cpp: In function ‘int main()’:
prog.cpp:14:30: error: cannot call constructor ‘A<float>::A’ directly [-fpermissive]
A<float> a(A<float>::A<int>());
^
prog.cpp:14:30: error: for a function-style cast, remove the redundant ‘::A’ [-fpermissive]
prog.cpp:14:30: error: no matching function for call to ‘A<float>::A()’
prog.cpp:14:30: note: candidates are:
prog.cpp:8:2: note: template<class U> A<T>::A()
A() {
^
prog.cpp:8:2: note: template argument deduction/substitution failed:
prog.cpp:14:30: note: couldn't deduce template parameter ‘U’
A<float> a(A<float>::A<int>());
^
prog.cpp:4:7: note: A<float>::A(const A<float>&)
class A
^
prog.cpp:4:7: note: candidate expects 1 argument, 0 provided