fork(7) download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <string>
  4. #include <typeinfo>
  5.  
  6. //////////////////////////////////////////////////////////////////////////////////////
  7.  
  8. class Bar
  9. {
  10. public:
  11. enum TYPE{};
  12. };
  13.  
  14. //////////////////////////////////////////////////////////////////////////////////////
  15.  
  16. template<typename T>
  17. class Foo
  18. {
  19. public:
  20. template<typename P>
  21. void setValue1();
  22.  
  23. template<typename P, int>
  24. void setValue2();
  25.  
  26. template<typename P, typename P::TYPE>
  27. void setValue3();
  28.  
  29. private:
  30. T m_value;
  31. };
  32.  
  33. //////////////////////////////////////////////////////////////////////////////////////
  34.  
  35. template<typename T>
  36. template<typename P>
  37. void Foo<T>::setValue1()
  38. {
  39. }
  40.  
  41. template<typename T>
  42. template<typename P, int>
  43. void Foo<T>::setValue2()
  44. {
  45. }
  46.  
  47. template<typename T>
  48. template<typename P, typename P::TYPE>
  49. void Foo<T>::setValue3()
  50. {
  51. }
  52.  
  53. //////////////////////////////////////////////////////////////////////////////////////
  54.  
  55. int main()
  56. {
  57. Foo<Bar::TYPE> f1;
  58.  
  59. f1.setValue1<Bar>(); // Compiles
  60. f1.setValue2<Bar, int>(); // ERROR
  61. f1.setValue3<Bar, Bar::TYPE>(); // ERROR
  62.  
  63. return EXIT_SUCCESS;
  64. }
  65.  
  66. //////////////////////////////////////////////////////////////////////////////////////
  67.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:60: error: no matching function for call to ‘Foo<Bar::TYPE>::setValue2()’
prog.cpp:61: error: no matching function for call to ‘Foo<Bar::TYPE>::setValue3()’
stdout
Standard output is empty