fork download
  1. #include <iostream>
  2.  
  3. template <typename T> struct identity { typedef T type; };
  4.  
  5. template<typename DT, int DV, void (DT::*DF)(int)>
  6. struct Description
  7. {
  8. typedef DT T; // OK
  9. static const int V = DV; // OK
  10. };
  11.  
  12. template <typename DT, int DV, void (DT::*DF)(int)>
  13. typename identity<void (DT::*)(int)>::type function(Description<DT, DV, DF>) {
  14. return DF;
  15. }
  16.  
  17. struct TestClass
  18. {
  19. void TestFunc( int x ) { std::cout << "Value is: " << x << std::endl; }
  20. };
  21.  
  22. int main()
  23. {
  24. typedef Description<TestClass, 5, &TestClass::TestFunc> TCD;
  25. TCD tcd;
  26.  
  27. TestClass t;
  28. (t.*function(tcd))(5);
  29. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
Value is: 5