How to inherit std :: iterator correctly

Guys, if I have a class as shown below:

template<class T>
class X
{
T** myData_;
public:
class iterator : public iterator<random_access_iterator_tag,/*WHAT SHALL I PUT HERE? T OR T** AND WHY?*/>
{
T** itData_;//HERE I'M HAVING THE SAME TYPE AS MAIN CLASS ON WHICH ITERATOR WILL OPERATE
};
};

Questions are in the code next to the corresponding lines.
Thank.

+3
source share
3 answers

As a starting point, your value type should be the type of object that your container holds. My guess would be either T or T *, you really do not provide enough information to say. See here for an explanation of what the various options mean. The rest can often be left as default values.

+2
source

, , . T.

, , , .

, std::iterator , typedef, .

-1

, Boost.Iterator

-2

Source: https://habr.com/ru/post/1742510/


All Articles