Const iterators

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Chrismann

    #1

    Const iterators

    Hi,

    someone told me that STL const_iterators are faster than non-const
    iterators. Is this really true? And if so, why?

    I though that const_iterators should be used when possible in
    order to avoid side effects (no accidental writes). But I never heard
    of a speed-up.

    Regards,
    Chris
  • Pierre Barbier de Reuille

    #2
    Re: Const iterators

    Christian Chrismann wrote:
    Hi,
    >
    someone told me that STL const_iterators are faster than non-const
    iterators. Is this really true? And if so, why?
    >
    I though that const_iterators should be used when possible in
    order to avoid side effects (no accidental writes). But I never heard
    of a speed-up.
    >
    Regards,
    Chris
    for a good answer:



    very nice writing :)

    Pierre

    Comment

    • Pierre Barbier de Reuille

      #3
      Re: Const iterators

      Christian Chrismann wrote:
      Hi,
      >
      someone told me that STL const_iterators are faster than non-const
      iterators. Is this really true? And if so, why?
      >
      I though that const_iterators should be used when possible in
      order to avoid side effects (no accidental writes). But I never heard
      of a speed-up.
      >
      Regards,
      Chris
      I forgot ... the short answer is "no, it is not quicker to run", the
      long answer is in the article.

      Pierre

      Comment

      Working...