내가 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에 있습니까?
VS 2012 (Visual C++ 11 월 2012 CTP)의 Variadic Template도 설치되어 있습니다. – myWallJSON
([온라인 컴파일러 버전 확인]) – myWallJSON
아니요 VS2012 업데이트 1 후에 이러한 코드를 컴파일 할 수 있습니다. – myWallJSON