g++으로 template 컴파일 warning 인데, 무슨 의미인지 모르겠네
글쓴이: ssehoony / 작성시간: 금, 2004/10/01 - 8:18오후
Quote:
chart_d.cpp: In function `int candle_read_file(std::vector<TYPE1, std::allocator<_CharT> >&, unsigned int, int, int, int)':
chart_d.cpp:1512: warning: `std::vector<TYPE1, std::allocator<_CharT>>::iterator' is implicitly a typename
chart_d.cpp:1512: warning: implicit typename is deprecated, please see the documentation for details
위와 같은 문구가 나오는데요.
위의 상황은 다음 상황에서 오류가 난건데요
Quote:
template<typename TYPE1>
int candle_read_file(vector<TYPE1>& vBuf, uint count, int acode, int BodyType, int time_unit)
이렇게 선언된 함수 내에 TYPE1 이라는 타입의 vector 생성에 이상없는데,
즉 vector<TYPE1> vBuf; 하는 식의 변수 선언은 이상없는데
vector<TYPE1>::iterator it; 라고 하는 부분이 문제 인 듯 하네요.
Quote:
warning: implicit typename is deprecated, please see the documentation for details
이런식의 자상한 문구는 감사한데 어떤 문서의 어디를 봐야 하는지...
이거 몇시간 삽질한 것 같네요.
해결 방법을 좀 가르쳐 주십시요.
설마 템플릿 함수 안에서 다른 템플릿을 사용할 수 없나요?
Forums:
C++ FAQ가 있다면 유력한 후보감인 질문입니다. :) typ
C++ FAQ가 있다면 유력한 후보감인 질문입니다. :)
typename vector<TYPE1>::iterator it;
로 쓰세요. 템플릿에서 type parameter TYPE1에 의존하는 형명 앞에는 typename을 써야 합니다.
어떤 문서를 봐야 하느냐고 물으셨는데 가장 믿을 만한 문서는 역시 표준입니다.
그리고 괜찮다고 평가받는 C++ 책에는 다 나옵니다. 다음은 표준에서 발췌한 것입니다.
typename 키워드에 대한 질문에서 다루어 졌던 내용이군요.typ
typename 키워드에 대한 질문에서 다루어 졌던 내용이군요.
typename이 쓰여지는 몇 가지 경우에 대해 아래의 링크에 몇 개의 댓글이 있습니다.
http://bbs.kldp.org/viewtopic.php?t=43061
링크를 보시기 전에 상식적으로 생각을 해봐도
typename vector<TYPE1>::iteraotr it;
에서 typename 이 없다면 iterator가 vector클래스의 statc member인지 아니면 nested class 선언인지 complier가 명확히 알 수 있는 방법이 없겠지요.
Life rushes on, we are distracted
댓글 달기