0

意味をなさない奇妙なタイプミスが発生しています。これは C++ コンパイラの問題ではないかと心配しています (10.6.8 と Xcode 3.x を搭載した Mac)。誰かが実際に問題を見つけることができれば、私は感謝します:

template<typename T> int getIdxInVector(const std::vector<T>&  vec, const T& toMatch)
{
std::vector<T>::const_iterator cit = std::find(vec.begin(),vec.end(),toMatch);
return( cit != vec.end() ? cit - vec.begin() : -1 );
}

ここに私が得ているエラーがあります:

LooseFunctions.h:27: error: expected `;' before 'cit'
LooseFunctions.h:28: error: 'cit' was not declared in this scope
LooseFunctions.h:27: error: dependent-name 'std::vector<T,std::allocator<_CharT> >::const_iterator' is parsed as a non-type, but instantiation yields a type
LooseFunctions.h:27: note: say 'typename std::vector<T,std::allocator<_CharT> >::const_iterator' if a type is meant

助けてくれてありがとう!

4

1 に答える 1