Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ProtobufDataModels.pb.h"
- #include <string>
- #include <iostream>
- #include <memory>
- template <class T>
- static void SendProto(T * message);
- template <class T>
- void SendProto(T * message)
- {
- WrapperMessage wm;
- if (std::is_same<T, InputChecking>::value)
- {
- std::shared_ptr<InputChecking> mes(message);
- std::string msg;
- message->SerializeToString(&msg);
- std::cout << msg << std::endl; // all ok
- wm.set_allocated_mes_inputchecking(mes.get()); // crash there
- }
- else if (std::is_same<T, RegistrationRequest>::value)
- {
- }
- }
- int main()
- {
- InputChecking * inputChecking = new InputChecking();
- inputChecking->set_login("Jack");
- SendProto(inputChecking);
- std::cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement