serializing a class which has a object pointing to another class. (help me serialize the class used in the provided example)
Ragu9967 opened this issue · comments
Hi, im currently working in a project in which im using your library.
Im facing some difficulty in serializing a class with has a object pointer to another seperate class.
In this example (link) geeks for geeks code, how do i serialize using the hps library ??
You have to either specialize the serialize and parse method of your class or use unique_ptr instead of raw pointer.
okay but it would be great if you give me a example :-)
If you really have to use raw pointers , you can start with this example https://github.com/jl2922/hps/blob/master/src/container/unique_ptr_serializer.h , changing unique_ptr to raw pointers.
Otherwise, there is tons of good tutorials online on how to use unique_ptrs (what I would recommend), they avoids memory leaks and have almost no performance overhead if optimization is turned on, plus my library can serialize them out of the box.