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
  • 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