fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T>
  7. struct HvVector
  8. {
  9. typedef std::vector<T> rt;
  10. };
  11.  
  12. class LetYouDo
  13. {
  14. public:
  15. template<typename CLASS, typename TYPE>
  16. LetYouDo(const std::string& name, TYPE (CLASS::*field))
  17. {
  18. std::cout << "3" << std::endl;
  19. }
  20.  
  21. template<typename CLASS, typename TYPE>
  22. LetYouDo(const std::string& name, typename HvVector<TYPE>::rt (CLASS::*field), TYPE* p)
  23. {
  24. std::cout << "4" << std::endl;
  25. }
  26. };
  27.  
  28. class Victim
  29. {
  30. public:
  31. int m1;
  32. HvVector<int>::rt m2;
  33. };
  34.  
  35. int main()
  36. {
  37. Victim v;
  38. v.m1 = 10;
  39. v.m2.push_back(10);
  40. LetYouDo o1("m1", &Victim::m1);
  41. LetYouDo o2("m2", &Victim::m2, static_cast<int*>(0));
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
3
4