Skip to content
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

Serializing collections with non-default constructible data #2805

Merged
merged 2 commits into from Aug 13, 2017

Conversation

AntonBikineev
Copy link
Contributor

@AntonBikineev AntonBikineev commented Aug 7, 2017

This fixes #2795

value_type& ref = reinterpret_cast<value_type&>(storage);
load_construct_data(ar, &ref, 0);
ar >> ref;
collection.push_back(ref);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be

collection.push_back(std::move(ref));

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks!

sizeof(value_type), alignof(value_type)>;

collection.clear();
while (size-- > 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to call collection.reserve(size); here (at least for vector and deque etc.)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good note, thanks!

template <class Archive, class T>
void save_construct_data(Archive&, T*, unsigned)
{
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a HPX_ASSERT(false); if this function is supposed to never be called.

template <class Archive, class T>
void load_construct_data(Archive&, T* t, unsigned)
{
::new (t) T;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, please add HPX_ASSERT(false);

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks1

@hkaiser
Copy link
Member

hkaiser commented Aug 8, 2017

@krivenko could you please verify whether this is solving your issue?

@hkaiser
Copy link
Member

hkaiser commented Aug 8, 2017

@hkaiser
Copy link
Member

hkaiser commented Aug 9, 2017

@AntonBikineev will you have time to look into @krivenko's problems or do you want me to do that?

@AntonBikineev
Copy link
Contributor Author

AntonBikineev commented Aug 9, 2017 via email

@hkaiser
Copy link
Member

hkaiser commented Aug 11, 2017

@krivenko please let us know if you're ok with these changes.

@hkaiser
Copy link
Member

hkaiser commented Aug 11, 2017

This was approved by @krivenko here: #2795.

@AntonBikineev
Copy link
Contributor Author

@hkaiser I don't have permissions to merge this PR, could you do this please (if you feel it's ready)?

@hkaiser
Copy link
Member

hkaiser commented Aug 12, 2017

@AntonBikineev I will do that. Let's get some of the other, older PRs in first.

@hkaiser hkaiser merged commit cc20429 into master Aug 13, 2017
@hkaiser hkaiser deleted the nondefault_ctor_ser branch August 13, 2017 11:36
@hkaiser
Copy link
Member

hkaiser commented Aug 18, 2017

@AntonBikineev Anton, sorry for getting back to this, but why did you use a different mechanism to construct an instance of non-default-constructable types here than we've been using for serializing single instances of such types?

@AntonBikineev
Copy link
Contributor Author

AntonBikineev commented Aug 21, 2017 via email

@hkaiser
Copy link
Member

hkaiser commented Aug 21, 2017

@AntonBikineev see #2849 for how I propose to unify things. Please have a look.

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

Successfully merging this pull request may close these issues.

Serialization of types without default constructor
2 participants