Possible Duplicate:
“invalid use of incomplete type” error with partial template specialization부분 전문화
왜이 작업을 수행 할 수있는 그 것이다 두 번째 경우를 들어
template <typename> struct C {};
template <typename T>
struct A
{
void foo(int);
};
template <typename T>
void A<C<T> >::foo(int)
{
}
을, GCC는 다음과 같은 오류를 제공합니다 :
test.cpp:10:23: error: invalid use of incomplete type 'struct A<C<T> >'
test.cpp:4:8: error: declaration of 'struct A<C<T> >'
EDIT :
두 번째 예제가 허용되지 않는 이유를 설명 할 때 멤버 함수를 템플릿으로 만드는 것은 어떤 예제가 효과가 있고 어떤 효과가 없는지 고려하지 않습니다.
template <typename T>
struct A
{
template <typename U>
void foo(U);
};
template <>
template <typename U>
void A<int>::foo(U)
{
}
을하지만이되지 않습니다 : 그것은이 여전히 작동한다
template <typename> struct C {};
template <typename T>
struct A
{
template <typename U>
void foo(U);
};
template <typename T>
template <typename U>
void A<C<T> >::foo(U)
{
}
그래서 이유 세 번째 예는 전체 전문이 아니기 때문에 함수 템플릿은 (완전히 전문화 할 수있는 수 없습니다 템플릿 매개 변수 U
이 여전히 존재 함), 아직 작동합니다.
@Mankarse 다른 문제 인 것 같습니다. –