Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are variadic functions deprecated?

Are variadic-functions kind of deprecated since C++11 has variadic template functions ? More specifically, do variadic-function have any advantage in a particular situation ? I know variadic-macros can have their uses. What about variadic functions ?

like image 708
Nicolas Avatar asked Jan 28 '26 05:01

Nicolas


1 Answers

Variadic templates are variadic at compile time; variadic functions are variadic at run time. In other words, a variadic template function is compiled to accept however many parameters are passed to it, while a regular variadic function is compiled to accept any number of parameters.

You can put a variadic function like printf into a library and ship it to somebody to use without source code. You cannot do that with a template function because its source code needs to be available to the caller.

like image 84
Gabe Avatar answered Jan 29 '26 19:01

Gabe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!