it had been several times discussed in other subjects that it is not recommended to use variadic function because the compiler can't check the type of provided arguments.
But what about if the user knows exactly the type can be e.g. std::string. Could anything still go wrong here too?
regards
You may only pass "plain old data" (POD) types as variadic arguments. These are basic types (including pointers), and simple aggregates of other POD types; anything with non-trivial constructors, destructor, base classes or virtual functions are not POD. Passing a non-POD type gives undefined behaviour.
If you really want to use variadic functions in conjunction with complex types, you will have to pass them by pointer.
UPDATE: The C++0x draft relaxes "undefined behaviour" to "conditionally-supported, with implementation-defined semantics". I'm assuming this means you'll either get correct runtime behaviour (using the copy constructor/destructor where necessary), or a compile error, but never incorrect runtime behaviour from a conforming implementation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With