Skip to content

[container.requirements] Simplify Returns specification for try_emplace #7892

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Eisenwave
Copy link
Contributor

Fixes #7881.

@jensmaurer
Copy link
Member

@jwakely , since we already say we do as-if emplace in the "Effects", this change seems to be a nice clarification. What do you think?

@jwakely
Copy link
Member

jwakely commented May 26, 2025

Why not just Equivalent to: Returns ... except that ... ?

@Eisenwave Eisenwave force-pushed the emplace-hint-returns branch from cb056ae to 806be71 Compare May 26, 2025 18:29
@Eisenwave
Copy link
Contributor Author

@jwakely that seems better, yes.

I've also deleted a bunch of the adjacent specifications because those are inherited when "Equivalent to" is specified. Let me know if that's correct.

@Eisenwave Eisenwave force-pushed the emplace-hint-returns branch from 806be71 to 132931e Compare May 26, 2025 18:34
Copy link
Member

@jwakely jwakely left a comment

Choose a reason for hiding this comment

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

I think the \result elements should remain, those are still useful (and [structure.specifications] p4 does not say that Effects: Equivalent to implies the Result: element).

I prefer the original form of "is a hint ... Implementations are permitted to ignore the hint." rather than "is an ignorable hint..."

@Eisenwave Eisenwave force-pushed the emplace-hint-returns branch from 132931e to 4c7ff44 Compare May 28, 2025 04:16
@Eisenwave Eisenwave requested a review from jwakely May 28, 2025 04:16
with the key equivalent to the newly inserted element.
The \tcode{const_iterator} \tcode{p} is a hint
Equivalent to: \tcode{return a.emplace(std::forward<Args>(args)...).first},
expect that the \tcode{const_iterator} \tcode{p} is a hint
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
expect that the \tcode{const_iterator} \tcode{p} is a hint
except that the \tcode{const_iterator} \tcode{p} is a hint

@@ -3233,15 +3233,10 @@

\pnum
\effects
Equivalent to \tcode{a.emplace(std::forward<Args>(args)...)},
Equivalent to: \tcode{return a.emplace(std::forward<Args>(args)...).first},
Copy link
Member

Choose a reason for hiding this comment

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

I've just realised that this doesn't work, because a_uniq.emplace and a_eq.emplace return different things. It's not a pair for a_eq, so you can't do .first

So maybe what you had before was better, sorry.

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

Successfully merging this pull request may close these issues.

[container.requirements] Confusing "Returns" paragraph under a.emplace_hint(p, args)
3 participants