迭代stt :: vector类<t,u,=“”v =“”>模板类中的指针</t,>

时间:2011-11-06 06:33:25

标签: c++ templates stl iterator

  

可能重复:
  Question about vector iterator in template functions

我有一个模板类,其中包含另一个模板类(Flare::Functor)的向量。我宣布Flare::Functor*的向量是这样的:

template<typename T, typename U = void, typename V = void>
class Signal
{
public:
    ...
    std::vector<Flare::Functor<T, U, V>*> handlers;
}

这很好,但是当我尝试迭代向量(在另一个函数中)时,就像这样:

void raise(U arg1, V arg2)
{
            for (std::vector<Flare::Functor<T, U, V>*>::iterator it = handlers.begin(); it < handlers.end(); ++it)
                ...
}

gcc会出现以下错误:

include/signal.h: In member function ‘void Flare::Signal<T, U, V>::raise(U, V)’:
include/signal.h:31: error: expected `;' before ‘it’
include/signal.h:31: error: ‘it’ was not declared in this scope

像这样声明迭代器:

std::vector<Flare::Functor<void, void, void>*>::iterator it

似乎完全正常。

0 个答案:

没有答案