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
Add serialization for std::set (as there is for std::vector and std::map) #1658
Conversation
Oops. My bad, my name. Changed to "ae" |
for (std::size_t i = 0; i < size; ++i) { | ||
T t; | ||
ar >> t; | ||
set.insert(set.end(), t); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should make use of move semantics here.
All comments should be addressed by now. Once this is merged I'll follow up with a separate PR to update map.hpp and vector.hpp. |
@sithhell using size_t shouldn't be a problem and user doesn't need to be aware of it, because it's explicitly casted to int64_t/uint64_t in archives' code. |
boost::uint64_t size = set.size(); | ||
ar << size; | ||
if(set.empty()) return; | ||
for (typename std::set<T, Allocator>::iterator i = set.begin(); i != set.end(); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look right, Allocator is the last template argument. Why not write this as
for (T const& elem: set) ar << elem;
to avoid problems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello!
New message, please read http://polatlicocukdiyari.com/increasing.php?0ooah
@AntonBikineev I hope it does not get casted to a 32bit but a 64bit value inside the archive.. |
@hkaiser any integer always gets casted to 64 bit value. BTW, that behaviour may lead to narrowing when serializing something like boost::uint128_type. |
@AntonBikineev So if I have 1000 int they'll take up 8k, not 4k? Is that what we want? |
Am 15.07.2015 8:05 nachm. schrieb "Anton Bikineev" <notifications@github.com
That sounds awfully wrong, I hope that's not the case. We've been bitten by |
@Sithell my understanding is following. when you use
it calls
Sorry for the mess, here it is: |
On 07/15/2015 08:57 PM, Anton Bikineev wrote:
You are right ... my bad. Some issues we've had in the past with |
@AntonBikineev Could you verify what happens for uint128_t, please? |
The PR LGTM now. |
@hkaiser yeah, just reproduced this with the help of debugger. A half of most significant bits are cut off. What do you think would be more appropriate here? Having overload for this or just leave it as is to not mess the code? |
Could you please add an appropriate overload for platforms supporting that type? |
Add serialization for std::set (as there is for std::vector and std::map)
No description provided.