C++ 如何实现 spreading array 的参数?
PHP中文网
PHP中文网 2017-04-17 13:09:33
0
2
615

形参 (parameters) 类似

f(a, ...)

的形式。

那么函数体应该如何实现?

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
刘奇

Since the question is about C++, then

template<typename ...T>
void f(int a, T... t);

Of course that is the case, and then you can access every value in t through simple template metaprogramming techniques.

大家讲道理

The description of the problem is not very clear. I assume you want to know how to obtain the ... parameter in C language and see how to use va_list, va_start and the like.
http://en.cppreference.com/w/cpp/utility/variadic/va_start
http://en.cppreference.com/w/cpp/utility/variadic/va_list

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template