Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include "ProtobufDataModels.pb.h"
  2. #include <string>
  3. #include <iostream>
  4. #include <memory>
  5.  
  6. template <class T>
  7. static void SendProto(T * message);
  8.  
  9. template <class T>
  10. void SendProto(T * message)
  11. {
  12. WrapperMessage wm;
  13.  
  14. if (std::is_same<T, InputChecking>::value)
  15. {
  16. std::shared_ptr<InputChecking> mes(message);
  17.  
  18. std::string msg;
  19. message->SerializeToString(&msg);
  20. std::cout << msg << std::endl; // all ok
  21.  
  22. wm.set_allocated_mes_inputchecking(mes.get()); // crash there
  23.  
  24. }
  25. else if (std::is_same<T, RegistrationRequest>::value)
  26. {
  27. }
  28.  
  29. }
  30.  
  31. int main()
  32. {
  33. InputChecking * inputChecking = new InputChecking();
  34. inputChecking->set_login("Jack");
  35.  
  36. SendProto(inputChecking);
  37.  
  38. std::cin.get();
  39.  
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement