Monday 15 June 2015

c++ - Why does reverse_iterator doubly define its nested types? -


It appears that the itater adapter reverse_title defines its nested types in a special form From, which makes it public with std :: iterator iterator_category , value_type , inter_type , indicator and context . Except for iterator_category and value_type , all of these are clearly edited again in the definition of the typed 'class.

24.5.1.1 Class Template Reverse_Eterator [reverse. Etter]

  Namespace CSS {template & lt; Square iterator & gt; Classic reverse_title: Public Iterator & Lt; Tippanam Iterator_trate & lieutenant; Iterator & gt; :: Iterator_grid, Typnim Iterter_tratt & lt; Iterator & gt; :: value_type, typename iterator_traits & lt; Iterator & gt ;: inter_type, typename iterator_traits & lt; Iterator & gt; :: indicator, typename iterator_traits & lt; Iterator & gt; :: References & gt; ; {Public: Type Iter Eater_type; Typedef typename iterator_traits & lt; Iterator & gt; :: inter_type inter_type; Typipip typename iterator_traits & lt; Iterator & gt; :: Reference Reference; Typedef typename iterator_traits & lt; Iterator & gt; :: Pointer Pointer; // ... the rest of the class};  

Question : Why the definition of duplication? Is it only for the purposes of the exhibition, or is it more? And iterator_category and value_type

for a while For, they are moving away from using the std :: iterator as the base code, and to specify that each interseer should define the correct type of names.

When they specify the base class in the standard, then in the same way, the implementation of the class prevents the implementation, even if the only real intention was to specify that the iterator should define some names Required. Specifically, you can define is_base_of that the std :: iterator is the base class of a std :: reverse_iterator . No, there is no polymorph, so it is very foolish and meaningless to do this, but if you do this, then the current standard says that should return true.

It (me) as if it is in the process of walking with at least one accidental halfway point (more or less accidentally) for which std :: iterator Is used as a base class, and should be defined in the std :: reverse_iterator by specifying the names (and also, along with other other iterators).

In the history of those who care, this includes:


They were provided for almost the same reason std :: iterator (i.e., only to provide some typographs in one derived class) so that the reason behind removing them is as the base class.


1 comment: