   C++ and var_list
  Is there a C++ alternative to these?va_argva_end va_startHow to implement a function in C++ with variable number of arguments?   
Quote:Original post by NamelessTwoIs there a C++ alternative to these?va_argva_end va_startTry this.#include using namespace std;Quote:How to implement a function in C++ with unknown number or parameters?You can't pass objects through the ellipsis.  You can pass pointers to objects.By using the ellipsis, you forfeit the string type checking and compile-time safety available through C++.Notice how in the C++ standard library the use of varargs functions is replaced by chaining operators (eg. cout vs. printf).   ;  See boost::format for an example where C++ operator chaining improved on the vast shortcomings of the printf-style ellipsis construct.Can't resist to quote Zahlman's signature: "Basically whenever you invoke the dread ellipses construct you leave the happy world of type safety." -- SiCrane;  Here's a little example of how you can overload the << operator to perform chaining. Note that the result of the operation is a reference to the object itself.struct _func {    _func& operator <<(const int i) { /* do stuff with int */; return *this; }    _func& operator <<(const double f) { /* do stuff with double */ return *this; }    _func& operator <<(const std::string& s) { /* do stuff with string */; return *this; }} func;func << 42 << "Hello" << "world" << 3.14;;Quote:Original post by KonfusiusSee boost::format for an example where C++ operator chaining improved on the vast shortcomings of the printf-style ellipsis construct.However, even boost::format's developers note that it is considerably slower than printf. I guess I mention this just to bring notice to the fact that the 'best' way of doing something is not always the most suitable for a given situation, although I agree that the elipses should be avoided whenever possible.   