Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Toolchain

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...