Variadic Template in VS 2012 (Visual C++ November 2012 CTP)

梦想与她 提交于 2019-11-26 09:56:35

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!