fork download
  1. #include <cstdio>
  2.  
  3. typedef unsigned short wchar;
  4.  
  5. template<class T>
  6. class Test
  7. {
  8. public:
  9. template<class T2>
  10. Test(const T2* sz)
  11. {
  12. printf ("common version\n");
  13. }
  14.  
  15. void foo()
  16. {
  17. printf("foo\n");
  18. }
  19. protected:
  20. };
  21.  
  22. template<>
  23. template<>
  24. Test<char>::Test<wchar>(const wchar* sz)
  25. {
  26. printf ("a.w. str: %p\n", sz);
  27. }
  28.  
  29. template<>
  30. template<>
  31. Test<wchar>::Test<char>(const char* sz)
  32. {
  33. printf ("w.a. str: %p\n", sz);
  34. }
  35.  
  36.  
  37. int main()
  38. {
  39.  
  40. wchar a = 3;
  41. char b = '0';
  42.  
  43. Test<char> t1(&a);
  44. Test<char> t2(&b);
  45. Test<wchar> t3(&a);
  46. Test<wchar> t4(&b);
  47.  
  48. t1.foo();
  49. t2.foo();
  50. t3.foo();
  51. t4.foo();
  52. return 0;
  53. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
a.w. str: 0xbf8dbffe
common version
common version
w.a. str: 0xbf8dbffd
foo
foo
foo
foo