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

  • your vcs sucks

    I've been hacking on some Haskell stuff lately that's all managed in darcs and it's reminded me of an observation I made over two years ago now (see…

  • ghc llvm

    I read this thesis on an LLVM backend for GHC, primarily because I was curious to learn more about GHC internals. The thesis serves well as an…

  • found my bug!

    Not too interesting, but this has been bugging me for a week. Been working on a toy program that proxies a TCP connection. It was working fine for…

  • 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

  • your vcs sucks

    I've been hacking on some Haskell stuff lately that's all managed in darcs and it's reminded me of an observation I made over two years ago now (see…

  • ghc llvm

    I read this thesis on an LLVM backend for GHC, primarily because I was curious to learn more about GHC internals. The thesis serves well as an…

  • found my bug!

    Not too interesting, but this has been bugging me for a week. Been working on a toy program that proxies a TCP connection. It was working fine for…