Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofResolved status.

2951.iterator_traits should SFINAE forvoid* and function pointers

Section: 24.3.2.3[iterator.traits]Status:ResolvedSubmitter: Billy Robert O'Neal IIIOpened: 2017-03-24Last modified: 2020-09-06

Priority:3

View all otherissues in [iterator.traits].

View all issues withResolved status.

Discussion:

A customer recently triggered an unexpected SFINAE condition with classpath. We constrain the constructor that takesconst Source& by asking ifiterator_traits<Source>::value_type is one that's OK. This formsiterator_traits<void*>, which is a hard error, as it tries to formvoid&.

Pointers-to-non-object-type can never act as iterators, as they don't support pointer arithmetic (as we recently discovered inatomic<void*> /atomic<int(*)(int)>).

[2017-07 Toronto Wed Issue Prioritization]

Priority 3; Billy to look into arrays of unknown bounds

[2019-02; Kona Wednesday night issue processing]

This was resolved by the adoption ofP0896 in San Diego.

Proposed resolution:

This wording is relative toN4659.

  1. Change 24.3.2.3[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 = T;    using pointer = T*;    using reference = T&;    using iterator_category = random_access_iterator_tag;  };}

    and for pointers toconst 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;  };}

    -?- These partial specializations for pointers apply only whenT is an object type.


[8]ページ先頭

©2009-2026 Movatter.jp