Variadic Template in VS 2012 (Visual C++ November 2012 CTP)(VS 2012 中的可变参数模板(Visual C++ 2012 年 11 月 CTP))
问题描述
我安装了 Visual C++ Compiler 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 '...'
编译列表可变参数模板",所以我相信这应该可行.我确实理解智能感知可能不正确,但是编译器"应该可以工作.我不能从 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++ Compiler Nov 2012 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 中的可变参数模板(Visual C++ 2012 年 11 月 CTP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:VS 2012 中的可变参数模板(Visual C++ 2012 年 11 月 CTP)


基础教程推荐
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07