fork(3) download
  1. #include <iostream>
  2. #include <typeinfo>
  3. using namespace std;
  4.  
  5. struct mystruct{};
  6.  
  7. template<typename T>
  8. struct map;
  9.  
  10. //partial specification
  11. #define MAPPING(Key, Val) \
  12. template<> \
  13. struct map<Key> \
  14. { \
  15. typedef Val mapping_type; \
  16. };
  17.  
  18. MAPPING(mystruct, int)
  19.  
  20. template<typename T>
  21. void func(T t)
  22. {
  23. typename map<T>::mapping_type i = 999;
  24. cout<<i<<endl;
  25. }
  26.  
  27.  
  28. int main() {
  29. // your code goes here
  30. mystruct ms;
  31. func(ms);
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
999