iterator traits

Discussion in 'C++' started by toton, Mar 6, 2007.

  1. toton

    toton Guest

    Hi,
    I am developing one container of my own, which has iterators.
    the iterator is not derived from boost iterator facade (for some
    other reason), instead it is manually designed.
    Now when I am interfacing it with other boost libraries (like
    permutation_iterator, sub_range etc), I get a few errors related to
    iterator traits.
    Now my question
    1) What are the traits needed for iterator (and const iterator) ?
    any addition/deletion from the list ?
    1) size_type
    2) reference
    3) pointer
    4) value_type
    5) iterator_category
    6) difference_type

    2) For const_iterator what are the type of the following in a
    iterator ?
    1)value_type T or const T ?
    2) reference T& or const T&
    3) pointer T* or const T*

    Thanks
    abir
     
    toton, Mar 6, 2007
    #1
    1. Advertising

  2. toton wrote:
    > Hi,
    > I am developing one container of my own, which has iterators.
    > the iterator is not derived from boost iterator facade (for some
    > other reason), instead it is manually designed.
    > Now when I am interfacing it with other boost libraries (like
    > permutation_iterator, sub_range etc), I get a few errors related to
    > iterator traits.
    > Now my question
    > 1) What are the traits needed for iterator (and const iterator) ?
    > any addition/deletion from the list ?
    > 1) size_type
    > 2) reference
    > 3) pointer
    > 4) value_type
    > 5) iterator_category
    > 6) difference_type


    size_type is not required.

    >
    > 2) For const_iterator what are the type of the following in a
    > iterator ?
    > 1)value_type T or const T ?
    > 2) reference T& or const T&
    > 3) pointer T* or const T*


    T, const T& and const T*

    john


    >
    > Thanks
    > abir
    >
     
    John Harrison, Mar 6, 2007
    #2
    1. Advertising

  3. toton

    toton Guest

    On Mar 6, 1:39 pm, John Harrison <> wrote:
    > toton wrote:
    > > Hi,
    > > I am developing one container of my own, which has iterators.
    > > the iterator is not derived from boost iterator facade (for some
    > > other reason), instead it is manually designed.
    > > Now when I am interfacing it with other boost libraries (like
    > > permutation_iterator, sub_range etc), I get a few errors related to
    > > iterator traits.
    > > Now my question
    > > 1) What are the traits needed for iterator (and const iterator) ?
    > > any addition/deletion from the list ?
    > > 1) size_type
    > > 2) reference
    > > 3) pointer
    > > 4) value_type
    > > 5) iterator_category
    > > 6) difference_type

    >
    > size_type is not required.
    >
    >
    >
    > > 2) For const_iterator what are the type of the following in a
    > > iterator ?
    > > 1)value_type T or const T ?
    > > 2) reference T& or const T&
    > > 3) pointer T* or const T*

    >
    > T, const T& and const T*
    >
    > john
    >
    >
    >
    > > Thanks
    > > abir


    Many thanks. ow it solved the problem, and the code's are working with
    all of the boost library.
     
    toton, Mar 6, 2007
    #3
    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. Hendrik Maryns
    Replies:
    18
    Views:
    1,448
  2. greg
    Replies:
    6
    Views:
    468
    Dietmar Kuehl
    Jul 17, 2003
  3. Replies:
    6
    Views:
    665
    Jim Langston
    Oct 30, 2005
  4. Steven D'Aprano

    What makes an iterator an iterator?

    Steven D'Aprano, Apr 18, 2007, in forum: Python
    Replies:
    28
    Views:
    1,215
    Steven D'Aprano
    Apr 20, 2007
  5. ray
    Replies:
    1
    Views:
    1,368
    Robert Kern
    Jun 4, 2010
Loading...

Share This Page