내가 같은 자식 메서드 내에서 클래스의 가변 인자 템플릿 유형 목록을 확장하기 위해 노력하고있어 :명시 전문화 [MSVS '12 : 11월을 '12 CTP : 오류 C3522]
template<typename... P>
struct Foo
{
template<P...> // error C3522: 'P' : parameter
// pack cannot be expanded in this context
static void Bar(P... a){}
};
이 코드의 문제점 또는 MSVS '12 : 11 월 12 일 CTP 버그입니까?
은 (예,이 예에서 명시 적 템플릿 특수화 중복 알고있다.)
위의 내가 오류를 재현 할 수 간단한 경우입니다. 전체 코드는 다음과 같습니다
template<typename FuncSignature>
class Callback;
template<typename R, typename... P>
class Callback<R (P...)>
{
public:
Callback() : func(0), obj(0) {}
Callback& operator=(const Callback& rhs)
{ obj = rhs.obj; func = rhs.func; return *this; }
private:
typedef R (*FuncType)(const void*, P...);
Callback(FuncType f, const void* o) : func(f), obj(o) {}
private:
FuncType func;
const void* obj;
template<typename FR, typename... FP>
friend class FreeCallbackFactory;
};
template<typename R, typename... P>
class FreeCallbackFactory
{
private:
template<R (*Func)(P...)>
static R Wrapper(const void*, P... a)
{
return (*Func)(a...);
}
public:
template<R (*Func)(P...)>
inline static Callback<R (P...)> Bind()
{
return Callback<R (P...)>
(&FreeCallbackFactory::Wrapper<Func>, 0);
}
};
template<typename R, typename... P>
inline FreeCallbackFactory<R, P...>
GetCallbackFactory(R (*)(P...))
{
return FreeCallbackFactory<R, P...>();
}
void Test(){}
int main(int argc, char** argv){
Callback<void()> cb = GetCallbackFactory(&Test).Bind<&Test>()
}
너무 난 그냥 컴파일러의 버그가 있으리라 믿고있어 ++ g에서 잘 컴파일이 계속 발견 여전히 포인트는 하나 그들을 밖으로 확대 명시 적으로보다이 기타에 대한 가능한 해결 방법이 있습니다 하나씩?
편집 :
template <P...>
static void Bar(P... a);
이 템플릿으로 P...
값을 복용 함수를 선언 선언을 :This has been reported to the compiler team as a bug and a patch will be in the next release of the compiler. [Link]
이것은 MSVC : 11 월 12 일 CTP에 관한 것입니다. 그것은 내가 그 오류를 재현 한 가장 간단한 경우였다. 내가 프로젝트의 MSVC를 사용해야하지만 GCC에서 잘 컴파일되는 전체 코드로 질문을 업데이트했습니다. 지금까지 도움을 주셔서 감사 드리며 non-type 매개 변수에 대한 이해를 돕습니다. – LostOfThought