-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
Adding parallel::destroy and destroy_n #2676
Conversation
|
||
for (/* */; first != last; ++first) | ||
{ | ||
std::addressof(*first)->~value_type(); |
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.
Why do we need std::addressof here?
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.
Because the type returned from dereferencing first
could have an overloaded operator&()
. Alternatively we could write (*first).~value_type()
, however MSVC was complaining about this for some unknown reason.
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.
Yeah, the question was hinting at why not to use (*first).~value_type()
in the first place, MSVC not working is anwering that, thanks!
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.
LGTM
std::for_each(p, p + data_size, | ||
[&count](destructable v1) | ||
{ | ||
HPX_TEST_EQ(v1.value_, (std::uint32_t)0xcdcdcdcd); |
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 is technically UB, isn't it?
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.
It is... Do you have a better idea how to check whether an object actually was destroyed? We could perhaps simply use a counter to count invocations. Not sure.
It is... Do you have a better idea how to check whether an object
actually was destroyed? We could perhaps simply use a counter to count
invocations. Not sure.
Guess the counter is the only way here ... this test fails on a gcc
release build ...
|
This is related to #1141