Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7184179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:08:50+00:00 2026-05-28T18:08:50+00:00

I realize I can get the iterator reference by calling back() but why not

  • 0

I realize I can get the iterator reference by calling back() but why not return it with push_back() as well? Is it for performance reasons? Or is it due to exception safety (similar to why pop_back() doesn’t return the popped value)? In either case, please explain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:08:51+00:00Added an answer on May 28, 2026 at 6:08 pm

    Various insert functions return an iterator for a very simple reason: the caller does not necessarily know how to get an iterator to that element. map::insert and set::insert return one because otherwise, the caller would have to search for the element.

    When you do a vector::push_back, you know where the inserted element is. It’s --vector.end(). You don’t have to search for it; it’s always that location. You can get it in constant time, and pretty quick constant time at that.

    So there’s really no point in returning something that the user already knows.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize you can script Microsoft Office apps, but I'm looking for something more
I realize this would violate convention, but I'm curious to know if you can
Disclaimer: I realize I can generate this at runtime in Java, this was needed
How can you realize the usage of JNDI , with an example if possible?
I realize that it can depend on certain things (and obviously how efficient the
I've done numerous searches and I realize that I can just download this file
i am having problems with animation. Can't realize how to animate things in flex?
After reading E-myth Revisited, I realize that I can do a better job at
It just makes me go mad. I can't realize what the problem is. Please
I realize that I need to use a mailserver so people can contact me,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.