다음 사람이 VC9에서 오류를 생성하는 이유를 알고 있습니까?BOOST_FOREACH : STL 컨테이너를 사용할 때의 오류는 무엇입니까?
class Elem;
class ElemVec : public vector<Elem>
{
public:
void foo();
};
void ElemVec::foo()
{
BOOST_FOREACH(Elem& elem, *this)
{
// Do something with elem
}
return;
}
내가 오류는 다음과 같습니다 오류없이
error C2355: 'this' : can only be referenced inside non-static member functions
내가 지금 컴파일 한 유일한 (해킹) 솔루션입니다 :
void ElemVec::foo()
{
ElemVec* This = this;
BOOST_FOREACH(Elem& elem, *This)
{
// Do something with elem
}
return;
}
그 점을 지적 해 주셔서 감사합니다. 나는 Boost 1.35에있어, 나는 1.38로 업그레이드 할 것이고 당신에게 돌아갈 것이다. –
부스트 1.38에서 오류가 사라졌습니다. 고마워요! :-) –