VS 2012中的Variadic模板(Visual C ++ 2012年11月CTP) [英] Variadic Template in VS 2012 (Visual C++ November 2012 CTP)

查看:154
本文介绍了VS 2012中的Variadic模板(Visual C ++ 2012年11月CTP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了 Visual C ++编译器2012年11月CTP ,并创建了一个C ++控制台项目。我在

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);
}

然后我按F6在IDE中构建。我在第4行收到此错误

Then I pressed F6 to build in the IDE. I got this error on line 4

error C2143: syntax error : missing ',' before '...'

编译列表variadic templates,所以我相信这应该工作。我明白intellisense可能不正确,但'编译器'应该工作。我不能从IDE构建?我必须在某处启用某项功能吗? int i {4}; 似乎也不工作,我相信有效的统一初始化。

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.

推荐答案

在项目属性中,请务必选择 Microsoft Visual C ++编译器2012年11月CTP

In the Project Properties, make sure to select the Microsoft Visual C++ Compiler Nov 2012 CTP:

新的工具链不会取代现有的Visual C ++ 2012工具链,默认情况下不启用。

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.

这篇关于VS 2012中的Variadic模板(Visual C ++ 2012年11月CTP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆