VS 2012 中的可变参数模板(Visual C++ 2012 年 11 月 CTP)

2023-06-03C/C++开发问题
7

本文介绍了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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

无法访问 C++ std::set 中对象的非常量成员函数
Unable to access non-const member functions of objects in C++ std::set(无法访问 C++ std::set 中对象的非常量成员函数)...
2024-08-14 C/C++开发问题
17

从 lambda 构造 std::function 参数
Constructing std::function argument from lambda(从 lambda 构造 std::function 参数)...
2024-08-14 C/C++开发问题
25

STL BigInt 类实现
STL BigInt class implementation(STL BigInt 类实现)...
2024-08-14 C/C++开发问题
3

使用 std::atomic 和 std::condition_variable 同步不可靠
Sync is unreliable using std::atomic and std::condition_variable(使用 std::atomic 和 std::condition_variable 同步不可靠)...
2024-08-14 C/C++开发问题
17

在 STL 中将列表元素移动到末尾
Move list element to the end in STL(在 STL 中将列表元素移动到末尾)...
2024-08-14 C/C++开发问题
9

为什么禁止对存储在 STL 容器中的类重载 operator&amp;()?
Why is overloading operatoramp;() prohibited for classes stored in STL containers?(为什么禁止对存储在 STL 容器中的类重载 operatoramp;()?)...
2024-08-14 C/C++开发问题
6