Cleanest way to skip the load of an unwanted member

20 views
Skip to first unread message

Luca Dolci

unread,
May 20, 2025, 1:31:50 PMMay 20
to cere...@googlegroups.com
I want to skip the load of an object since that class is going to be eliminated from codebase, what's the cleanest way to do it?

I have this scenario:
class A
{
  size_t m_size;
  std::vector<float> m_x;
};

class B
{
  std::shared_ptr<A> m_a;
};

Class A is going to be deleted from codebase, and in class B it will be substituted by A::m_size; I have all my serialization function versioned so, from version 2 I was wandering how could I load the shared pointer to A and recover the wanted class member.

I already though about creating a struct that mimics A in it's members (let's call it DummyA) and in a specialized versioned load function, load it instead of A, since I think I can't de-serialize directly the size_t and the std::vector due to shared pointer and class version management.
Of course this won't work with polymorphic classes, but it's the best idea that I have. Do you have any suggestions? Do someone else faced the same problem?

Reply all
Reply to author
Forward
0 new messages