Skip to content

std::shared_ptr and std::unique_ptr serialization support #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JonathasValeriano opened this issue Apr 28, 2018 · 5 comments
Open

Comments

@JonathasValeriano
Copy link

Hi, do you have any plan to support std::shared_ptr and std::unique_ptr in the yas library?

@niXman
Copy link
Owner

niXman commented May 1, 2018

Hi,

Do you mean serialization of polymorphic types?

Repository owner deleted a comment from 7956968 Apr 29, 2022
@harsh777d
Copy link

Hi,
can yas handle runtime polymorphism?

@ambitslix
Copy link

Could you elaborate and give an example? I'm guessing you mean serialization via base pointer etc?

@harsh777d
Copy link

I want to serialize base pointer that can point to base/derived object. when it get deserialize It should return the proper object.

struct MyClass {
Base* ptr;
MyClass() {
ptr = new Derived(); // or new Base();
}

void serialize(Archive ar) {
ar & ptr;
}
}
when I deserialize, the ptr should point to correct type(Base/Derived).

@ambitslix
Copy link

I think the short answer is no. YAS de/serializes a set of data members that you specify per class. You have to make sure that whatever constructor you end up using after de-serialization will work correctly meaning will get you a proper object instance. As for runtime polymorphism the serialize/deserialize will work like any other function ptr would.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants