Quick A: There are several special cases where you may want that, but in general no.
Recently on SO:
Is there a case where ellipsis(vararg) should be preffered over variadic templates?
- If you provide a C API with C++ implementation, then templates are not an option for the API. Varargs are.
- If you need to support a compiler that doesn't support C++11 or newer standard, then variadic templates are not available. Varargs are.
- If you need a compilation firewall. I.e. you need to hide the implementation of the function from the header, then variadic template is not an option. Varargs are.
- On memory constrained systems (embedded), the different functions generated by the template may introduce too much bloat. That said, such systems are typically also real time, in which case varargs might also unacceptable due to branching and stack usage.
Add a Comment
Comments are closed.