Why the iterator_traits is needed?

Discussion in 'C++' started by izhak, Dec 29, 2011.

  1. izhak

    izhak Guest

    Why do we need the iterator_traits if it's just a simple redefinition of
    some of the Iterator concept's members?
    izhak, Dec 29, 2011
    #1
    1. Advertising

  2. izhak

    Bo Persson Guest

    izhak wrote:
    > Why do we need the iterator_traits if it's just a simple
    > redefinition of some of the Iterator concept's members?


    It's not just that.

    There is also a specialization for pointer, which doesn't have the
    concept members.

    Pointers are also iterators!


    Bo Persson
    Bo Persson, Dec 29, 2011
    #2
    1. Advertising

  3. izhak

    izhak Guest

    On Thu, 29 Dec 2011 17:58:14 +0100, Bo Persson wrote:

    > There is also a specialization for pointer, which doesn't have the
    > concept members.
    >
    > Pointers are also iterators!
    >
    >
    > Bo Persson


    Yes, now I understand... And for any other type, we my just specialize
    it, to make that type usable in stl. Clear, thanks.
    izhak, Dec 29, 2011
    #3
  4. izhakæ–¼ 2011å¹´12月30日星期五UTC+8上åˆ12時55分31秒寫é“:
    > Why do we need the iterator_traits if it's just a simple redefinition of
    > some of the Iterator concept's members?


    I think to understand an iterator is important.

    There are implementations of iterators.

    Iterators are different from recursions in implementations.

    In the abstract level the two does not differ too much.
    88888 Dihedral, Dec 30, 2011
    #4
  5. 88888 Dihedralæ–¼ 2011å¹´12月30日星期五UTC+8上åˆ8時42分32秒寫é“:
    > izhakæ–¼ 2011å¹´12月30日星期五UTC+8上åˆ12時55分31秒寫é“:
    > > Why do we need the iterator_traits if it's just a simple redefinition of
    > > some of the Iterator concept's members?

    >
    > I think to understand an iterator is important.
    >
    > There are implementations of iterators.
    >
    > Iterators are different from recursions in implementations.
    >
    > In the abstract level the two does not differ too much.


    But iterator in STL is more powerful. For example, there could be many
    instances of timers in different classes of objects.

    Each timer is defined clearly for the actions to be triggered in objects
    that can access the timer in the next timer update event.

    Thinking in the iterator way and the message driven mechanism is
    better than the MS call back mechanism.
    88888 Dihedral, Jan 8, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lieven

    iterator_traits

    Lieven, Dec 2, 2004, in forum: C++
    Replies:
    3
    Views:
    464
    Siemel Naran
    Dec 3, 2004
  2. chris
    Replies:
    8
    Views:
    494
    Tom Widmer
    Dec 10, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,842
    Smokey Grindel
    Dec 2, 2006
  4. Jess
    Replies:
    3
    Views:
    650
    Zeppe
    Jun 28, 2007
  5. Ioannis Vranos

    typename iterator_traits::pointer

    Ioannis Vranos, Jan 24, 2008, in forum: C++
    Replies:
    10
    Views:
    711
    Ioannis Vranos
    Jan 25, 2008
Loading...

Share This Page