나는 다음과 같이 템플릿 클래스 내부 decltype를 사용하는 것을 시도하고있다 : 잘 작동decltype은
#include <functional>
template <typename T>
class A
{
typedef decltype(std::bind(&A::f, std::declval<A>())) some_type;
void f();
};
,하지만 지금은 명시 적 전문성을 추가하고 싶습니다 :
template <>
class A<void>
{
typedef decltype(std::bind(&A::f, std::declval<A>())) some_type;
void f();
};
을
이번에는 g ++에서 오류를 제공합니다 :
test.cpp:14:33: error: incomplete type 'A<void>' used in nested name specifier
내가 뭘 잘못하고 있니? 나는 gcc 4.5를 사용하고있다.
편집 : 요하네스 의해 제안 내가의 형식 정의 위에 void f();
의 선언을 이동하면, 내가 할 (약간) 다른 오류 :
test.cpp:15:62: error: invalid use of incomplete type 'class A<void>'
test.cpp:13:1: error: declaration of 'class A<void>'
test.cpp:15:62: error: initializing argument 2 of 'std::_Bind<typename std::_Maybe_wrap_member_pointer<_Tp>::type(_ArgTypes ...)> std::bind(_Functor, _ArgTypes ...) [with _Functor = void (A<void>::*)(), _ArgTypes = {A<void>}, typename std::_Maybe_wrap_member_pointer<_Tp>::type = std::_Mem_fn<void (A<void>::*)()>]'
test.cpp:15:62: error: invalid use of incomplete type 'class A<void>'
test.cpp:13:1: error: declaration of 'class A<void>'
test.cpp:15:62: error: initializing argument 2 of 'std::_Bind<typename std::_Maybe_wrap_member_pointer<_Tp>::type(_ArgTypes ...)> std::bind(_Functor, _ArgTypes ...) [with _Functor = void (A<void>::*)(), _ArgTypes = {A<void>}, typename std::_Maybe_wrap_member_pointer<_Tp>::type = std::_Mem_fn<void (A<void>::*)()>]'
"A 무효을"는 문자 "전자"처럼 부족, 불완전한 * 입력 체계 *입니다. (너무 모호한가요? http://en.wikipedia.org/wiki/A_Void) –
@Steve LOL ... 유머 만이 코드를 컴파일하면 ... – HighCommander4
예, 죄송합니다. 실제로 질문에 도움을 줄 수 없습니다. –