fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #ifndef TEST_H
  5. #define TEST_H
  6.  
  7. class User;
  8.  
  9. template <class T>
  10. class Wrapper {
  11. public:
  12. template<class T>
  13. auto Callback(...) {};
  14. };
  15.  
  16. template<class T = User>
  17. class Library {
  18. public:
  19. T* node = nullptr;
  20. void utility() {
  21. T::Callback(node);
  22. }
  23. };
  24.  
  25. class User : public Wrapper<User> {
  26. public:
  27. static void Callback( class Wrapper* ) { std::cout << "Callback was called.\n"; }
  28. };
  29.  
  30. #endif // TEST_H
  31.  
  32. int main() {
  33.  
  34. Library<User> l;
  35. l.utility();
  36.  
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:12:14: error: declaration of template parameter ‘T’ shadows template parameter
     template<class T>
              ^~~~~
prog.cpp:9:11: note: template parameter ‘T’ declared here
 template <class T>
           ^~~~~
stdout
Standard output is empty