jeudi 17 novembre 2022

How would one go about serializing a shared_ptr

Here is a situation I am dealing with :

  1. There exists a function f() in process P1
  2. There exists a function g() in process P2
  3. f() in P1 wants to provide g() in P2 with objects like shared_ptr or unique_ptr or weak_ptr

One part of IPC is message serialization and I am interested to know answers to following questions :

a) Is it even possible to serialize these C++-11 smart pointer constructs as these in essence can be recursive constructs for instance a shared_ptr could be a shared_ptr to the root of a tree which in essence is a recursive data structure?

b) What libraries exist to do this?

c) How would g() then go about de-serializing these constructs?

P.S. : I did some research on Google before posting this but I am not able to find a definitive resource on this topic and hence a little confused. Thanks in advance!

Readings done


  1. Read about serialization and de-serialization
  2. Read about how boost tries to do serialization of smart pointers : https://theboostcpplibraries.com/boost.serialization-pointers-and-references

Aucun commentaire:

Enregistrer un commentaire