0

내가 simple C++11 code를 컴파일하려고 (내가 primaraly VS2010를 대상으로하며 2012 대 보조 옵션으로) they say는 컴파일하며 is compilable on some modern compilers 그래서 내가 좋아하는 코드를 포함하는 구조체를 컴파일하는 방법을 궁금해 :VS2010 및 VS2012 및 C++ 11 오류 C2059 : 구문 오류 : '...'해결 방법?

struct C { 
    A *_first__; 
    B *_second__; 
    C(A * _first__, B * _second__):_first__(_first__), _second__(_second__) { 
    } template < typename K, typename ... T > static auto _a_caller__(K * k, T && ... args)->decltype(k->a(std::forward <T> (args) ...)) { 
    return k->a(std::forward <T> (args)...); 
    } 
    template <typename...T> auto a(T &&...args)->decltype(_a_caller__(_first__, std::forward <T> (args)...)) { 
     return _a_caller__(_first__, std::forward <T> (args)...); 
    } 
    template <typename...T> auto a(T &&...args)->decltype(_a_caller__(_second__, std::forward <T> (args)...)) { 
     return _a_caller__(_second__, std::forward <T> (args)...); 
    } 
    template < typename K, typename...T > static auto _b_caller__(K * k, T && ... args)->decltype(k->b(std::forward <T> (args) ...)) { 
     return k->b(std::forward <T> (args)...); 
    } 
    template <typename...T> auto b(T &&...args)->decltype(_b_caller__(_first__, std::forward <T> (args)...)) { 
     return _b_caller__(_first__, std::forward <T> (args)...); 
    } 
    template <typename...T> auto b(T &&...args)->decltype(_b_caller__(_second__, std::forward <T> (args)...)) { 
     return _b_caller__(_second__, std::forward <T> (args)...); 
    } 
}; 

에서 VS 2010를 가능한 경우 vs2012에 있습니까?

답변

4

가변 인자 템플릿은 VS2010에서도 VS2012에서도 지원되지 않습니다 당신이 CTP를 사용하려는 경우 http://blogs.msdn.com/b/vcblog/archive/2012/11/02/visual-c-c-11-and-the-future-of-c.aspx

또한 Variadic Template in VS 2012 (Visual C++ November 2012 CTP) 참조 : 그들은 비록 VS2012 CTP에서 지원됩니다 http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx .

+0

VS 2012 (Visual C++ 11 월 2012 CTP)의 Variadic Template도 설치되어 있습니다. – myWallJSON

+0

([온라인 컴파일러 버전 확인]) – myWallJSON

+0

아니요 VS2012 업데이트 1 후에 이러한 코드를 컴파일 할 수 있습니다. – myWallJSON

관련 문제