Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Variadic templates are essential for simple, argument forwarding template functions. std::vector::emplace_back is a very simple example, this kind of use comes up now and then during work.

[1] https://en.cppreference.com/w/cpp/container/vector/emplace_b...

edit: This also shows that you don't have to be able to write variadic templates to reap the benefits of it. You can enjoy the benefits while using a library that uses it.



The key to understanding techniques based on templates is to realize that C++ templates are just another programming language that (a) is functional, (b) is interpreted at compile time, and (c) where values are C++ types.


Sure I've written variadic templates. But for this situation it feels quite forced.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: