fork download
  1. template <class T>
  2. struct Foo
  3. {
  4.  
  5. template <class U>
  6. struct Bar
  7. {
  8. Bar();
  9.  
  10. template <class X, class Y>
  11. void foo(typename Foo<X>::template Bar<Y> b)
  12. {
  13.  
  14. }
  15. };
  16.  
  17. };
  18.  
  19. int main()
  20. {
  21. //Foo<int>::Bar<int> b = Foo<char>::Bar<char>();
  22. Foo<int>::Bar<int> i;
  23. i.foo(Foo<char>::Bar<char>());
  24. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:23:30: error: no matching function for call to ‘Foo<int>::Bar<int>::foo(Foo<char>::Bar<char>)’
  i.foo(Foo<char>::Bar<char>());
                              ^
prog.cpp:23:30: note: candidate is:
prog.cpp:11:14: note: template<class X, class Y> void Foo<T>::Bar<U>::foo(const typename Foo<X>::Bar<Y>&) [with X = X; Y = Y; U = int; T = int]
         void foo(const typename Foo<X>::template Bar<Y>& b)
              ^
prog.cpp:11:14: note:   template argument deduction/substitution failed:
prog.cpp:23:30: note:   couldn't deduce template parameter ‘X’
  i.foo(Foo<char>::Bar<char>());
                              ^
stdout
Standard output is empty