Skip to content

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

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
seishun opened this issue May 17, 2025 · 4 comments · May be fixed by #7892
Open

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

seishun opened this issue May 17, 2025 · 4 comments · May be fixed by #7892

Comments

@seishun
Copy link

seishun commented May 17, 2025

An iterator pointing to the element with the key equivalent to the newly inserted element.

  • In containers with unique keys, an element is not always inserted, so there might be no "newly inserted element".
  • In containers with equivalent keys, there might be more than one element "with the key equivalent to the newly inserted element".
@jensmaurer
Copy link
Member

Would the phrasing

"Returns: The iterator returned by emplace."

address your concerns?

@jwakely ?

@seishun
Copy link
Author

seishun commented May 17, 2025

I'm not sure if it's correct to say that emplace returns an iterator in containers with unique keys.

@jensmaurer
Copy link
Member

Well, emplace returns a pair for containers with unique keys, and we pick the iterator part of that pair. It's still "the" iterator returned by emplace, since the other part of the pair is a boolean, thus not an iterator.

@seishun
Copy link
Author

seishun commented May 17, 2025

Then perhaps the "Returns" paragraph under a_uniq.emplace(args) should say "the returned iterator" for consistency, just like it already does under try_emplace throughout [containers].

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 a pull request may close this issue.

2 participants