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
[range.nonprop.cache] Clarify that emplace-deref does not require materialization of the result of *i before the initialization #4732
Conversation
…erialization of the result of *i
Out of curiosity, could you give an example for which this |
#include <new>
#include <type_traits>
struct S {
S() = default;
S(const S&) = delete;
S(S&&) = delete;
};
S deref() { return S{}; }
S s{};
void emplace_deref() {
s.~S();
new (&s) S(deref());
}
static_assert(!std::is_constructible_v<S, S>); |
Thanks! Should we maybe augment the note to say "... is_constructible can be false, but the above declaration of |
Or maybe: "If |
Maybe even, " |
Repeating "emplace_deref doesn't seem to add anything. |
Editorial meeting 2021-07-16: Go with Jens' suggestion. @timsong-cpp , please update your pull request accordingly. |
I used "movable" instead since |
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.
Thanks, looks good.
@tkoeppe , this seems ready to merge now. |
@tkoeppe The commit message on 1305740 is incorrect:
That invented initialization does not require In the future, I would appreciate an opportunity to comment on this kind of commit messages that are going to be attributed to me before they end up in main, instead of discovering them afterwards. |
@tkoeppe, this looks like the time for a force-push of master. |
@timsong-cpp Sorry about that! You're right -- could you please provide a new message (that explains the clarified subtlety), and I'll update that? |
How about:
|
A new note explains that `emplace-deref` requires implementations to avoid materialization of the result of `*i` before the initialization. This is implied by the normatively expressed requirement in terms of an invented initialization of a variable, but is easily overlooked.
Thank you, I updated that! |
Based on empirical evidence, the existing wording is too subtle, so this adds a note to make the implication more obvious.