V
V
Vi Vola2018-12-07 12:26:28
C++ / C#
Vi Vola, 2018-12-07 12:26:28

How to get a vector iterator with a struct type in a template class?

There is a class A.
Inside it there is a structure that contains a field with a template type.
In the f() function, for example, I need to get an iterator (in my case, for searching).
But why can't I declare an iterator?
It turns out in this form I can’t work with iterators at all?

template<typename T>
class A {
public:
    A();
    ~A();
    void f(void* o);

    typedef struct {
        T* t;
        int i;
    } t_t;

    std::vector<t_t> v;
};

template <typename T>
A<T>::A() {}

template <typename T>
A<T>::~A() {}

template <typename T>
void A<T>::f(void* o) {
    // объявление итератора не работает    
    // std::vector<t_t>::iterator it = v.begin();
    static_cast<T*>(o)->push();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2018-12-07
@hakain

typename std::vector<t_t>::iterator it = v.begin();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question