问题
I installed Visual C++ Compiler November 2012 CTP and created a C++ console project. I wrote this in
template<typename T>
void Test(T value){
}
template<typename T, typename... Args>
void Test(T value, Args... args){
Test(value);
Test(args...);
}
int main(){
Test(1,2,3);
}
Then I pressed F6 to build in the IDE. I got this error on line 4
error C2143: syntax error : missing \',\' before \'...\'
The compile list \"variadic templates\" so I believe this should work. I do understand intellisense may be incorrect however the \'compiler\' should work. Can I not build from the IDE? Do I have to enable something somewhere? int i{4};
doesn\'t seem to work either and I am sure thats valid uniform initialization.
回答1:
In the Project Properties, make sure to select the Microsoft Visual C++ Compiler Nov 2012 CTP:
The new toolchain does not replace the existing Visual C++ 2012 toolchain, and it is not enabled by default. It's installed side-by-side with the existing toolchain.
If you select the new toolchain, your program will compiler without error.
来源:https://stackoverflow.com/questions/13238408/variadic-template-in-vs-2012-visual-c-november-2012-ctp