template<class Type> struct iterator_traits<const Type*>

Discussion in 'C++' started by Taras_96, Apr 1, 2008.

  1. Taras_96

    Taras_96 Guest

    Hi everyone,

    I came across the following:

    " * There is also a third version for pointers to const to remove
    the const from the value type.

    template <class T>
    struct iterator_traits<const T*> {
    typedef T value_type;
    };
    " - http://www.cs.helsinki.fi/u/tpkarkka/alglib/k06/lectures/iterators.html#other-associated-types

    However, the site at http://msdn2.microsoft.com/en-us/library/zdxb97eh(VS.71).aspx
    shows that:

    "template<class Type>
    struct iterator_traits<const Type*> {
    typedef random_access_iterator_tag iterator_category;
    typedef Type value_type;
    typedef ptrdiff_t difference_type;
    typedef const Type *pointer;
    typedef const Type& reference;
    };" (ie: the const is in the typedef)

    Which one is correct?

    Thanks

    Taras
    Taras_96, Apr 1, 2008
    #1
    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:
    461
    Siemel Naran
    Dec 3, 2004
  2. chris
    Replies:
    8
    Views:
    493
    Tom Widmer
    Dec 10, 2004
  3. Jess
    Replies:
    3
    Views:
    648
    Zeppe
    Jun 28, 2007
  4. Javier
    Replies:
    2
    Views:
    559
    James Kanze
    Sep 4, 2007
  5. Ioannis Vranos

    typename iterator_traits::pointer

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

Share This Page