Evan Martin (evan) wrote in evan_tech,
Evan Martin
evan
evan_tech

(possibly dumb) c++ question

In the pattern
for (foo::iterator i = bar.begin(); i != bar.end(); ++i) ...
Does bar.end() return a new end iterator on each run through the loop? If so, isn't that inefficient (running a constructor, returning an object via the stack, etc.)?

Update: thanks everyone! The one-sentence answer is "yes, it returns via the stack, but no, it's often just a pointer so it's not inefficient".
Tags: c/c++, fourth wall
Subscribe

  • münchen

    On that note: I'm living in Munich for the next week plus a few days. Do I know anyone around here? (PS: The LJ → PubSubHubbub → Reader…

  • deb/rpm diffing tools

    Dear Linux hackers, Chrome tends to push minor updates (often security) pretty frequently. We'd like to operate as a good member of the Linux…

  • emacs

    I've been using vim for a very long time -- over ten years -- but over those years I've envied more and more the way emacs integrates other software.…

  • Post a new comment

    Error

    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 17 comments

  • münchen

    On that note: I'm living in Munich for the next week plus a few days. Do I know anyone around here? (PS: The LJ → PubSubHubbub → Reader…

  • deb/rpm diffing tools

    Dear Linux hackers, Chrome tends to push minor updates (often security) pretty frequently. We'd like to operate as a good member of the Linux…

  • emacs

    I've been using vim for a very long time -- over ten years -- but over those years I've envied more and more the way emacs integrates other software.…