template <typename T>
void dump_var(const std::vector<T>& var)
{
std::vector<T>::const_iterator iter = var.begin();
conststd::vector<T>::const_iterator iter_end = var.end();
for (; iter != iter_end; ++iter) {
dump_var(*iter);
}
}
위 코드는 다음과 같은 에러를 낸다.
implicit typename is deprecated, please see the documentation for details
다음과 같이 바꾸어 써야 한다.
std::vector<T>::const_iterator iter = var.begin();
conststd::vector<T>::const_iterator iter_end = var.end();
=>제대로 된 해결책
typename std::vector<T>::const_iterator iter = var.begin();
const typename std::vector<T>::const_iterator iter_end = var.end();
=> 잘못된 해결책 (같은 에러가 계속 난다.)
std::vector<typename T>::const_iterator iter = var.begin();
const typename std::vector<typename T>::const_iterator iter_end = var.end();
참고문서
http://www.gnu.org/software/gcc/bugs.html
-------------------------------------------
The new parser brings a lot of improvements, especially concerning name-lookup.
The "implicit typename" extension got removed (it was already deprecated since GCC 3.1), so that the following code is now rejected, see [14.6]:
template <typename> struct A
{
typedef int X;
};
template <typename T> struct B
{
A<T>::X x; // error
typename A<T>::X y; // OK
};
B<void> b;
댓글 없음:
댓글 쓰기