Vladimir Yanakiev Vladimir Yanakiev - 5 months ago 60
C++ Question

Is there a case where ellipsis(vararg) should be preffered over variadic templates

Variadic template have lot of pros, but is there a case when ellipsis(vararg) should be use

  1. If you provide a C API with C++ implementation, then templates are not an option for the API. Varargs are.

  2. If you need to support a compiler that doesn't support C++11 or newer standard, then variadic templates are not available. Varargs are.

  3. 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.

  4. 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.