Previous Entry Share Flag Next Entry
07:56 am, 24 Apr 06

(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".