Title
iterator_traits should work for pointers to cv T
Status
wp
Section
[iterator.traits]
Submitter
Billy Robert O'Neal III

Created on 2017-03-27.00:00:00 last changed 36 months ago

Messages

Date: 2017-07-15.22:58:07

Proposed resolution:

This wording is relative to N4659.

  1. Change [iterator.synopsis] as indicated:

    // [iterator.primitives], primitives
    template<class Iterator> struct iterator_traits;
    template<class T> struct iterator_traits<T*>;
    template<class T> struct iterator_traits<const T*>;
    
  2. Change [iterator.traits] as indicated:

    -3- It is specialized for pointers as

    namespace std {
      template<class T> struct iterator_traits<T*> {
        using difference_type = ptrdiff_t;
        using value_type = remove_cv_t<T>;
        using pointer = T*;
        using reference = T&;
        using iterator_category = random_access_iterator_tag;
      };
    }
    

    and for pointers to const as

    namespace std {
      template<class T> struct iterator_traits<const T*> {
        using difference_type = ptrdiff_t;
        using value_type = T;
        using pointer = const T*;
        using reference = const T&;
        using iterator_category = random_access_iterator_tag;
      };
    }
    
Date: 2017-07-15.22:58:07

[ 2017-07 Toronto Wed Issue Prioritization ]

Priority 0; move to Ready

Date: 2017-04-15.00:00:00

[ 2017-03-30, David Krauss comments ]

volatile pointers may not be well-behaved random-access iterators. When simple access incurs side effects, the multiple-pass guarantee depends on underlying (hardware) semantics.

Date: 2017-03-27.00:00:00

iterator_traits accepts pointer to volatile T*, but then says that the value_type is volatile T, instead of T, which is inconsistent for what it does for pointer to const T. We should either reject volatile outright or give the right answer.

History
Date User Action Args
2017-11-13 19:01:36adminsetstatus: voting -> wp
2017-10-17 18:34:55adminsetstatus: ready -> voting
2017-07-15 22:58:07adminsetmessages: + msg9380
2017-07-15 22:58:07adminsetstatus: new -> ready
2017-04-22 17:27:21adminsetmessages: + msg9158
2017-04-22 17:27:21adminsetmessages: + msg9157
2017-03-27 00:00:00admincreate