-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Won't have time to finish this one right now, but this solution should work well. 1) Realized there was no reason to do the deferring thing, we just register immediately after allocation and use that pointer, so got rid of some overhead in code/time on regular shared_ptr loads. 2) For cases with no default constructor the interface will be changing slightly. Instead of having the user do both the allocation and initialization, the user will only be responsible for the initialization. This works as follows: We allocate std::aligned_storage big enough for the type and pack it into a shared_ptr for the proper type with a custom deleter to correctly call the proper destructors. We'll wrap up this raw pointer in a new class called cereal::allocation (or similar) which will now be passed along with the archive as a reference to the load and allocate function. The user now loads up their data as before using the archive, and then instead of performing a raw call to operator new, they pass all of their arguments to the operator() of the cereal::allocation object which then performs a placement new into the aligned_storage (transparent to the user). Should resolve the circular reference problem too.
- Loading branch information
Showing
2 changed files
with
62 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters