fork download
  1. #include <iostream>
  2.  
  3. template <typename T>
  4. class A
  5. {
  6. public:
  7. template <typename U>
  8. A() {
  9. std::cout << sizeof(T) << ' ' << sizeof(U) << std::endl;
  10. }
  11. };
  12.  
  13. int main() {
  14. A<float> a(A<float>::A<int>());
  15. return 0;
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty