I want to use variadic template feature for my application but I don't want the objects to be passed by value (as objects are quite complex in my case). I want to pass them by reference (not as pointers).
void func() { } template<typename Function1, typename... FurtherFunctions> void func(Function1 f1, FurtherFunctions... further_functions) { // doing some processing here... }
How could I pass the arguments by reference and ensure that they are not copied?
Just say:
template <typename ...Args> int myfunction(Args & ... args) { /* ... */ }
Same for const Args & ... args
, Args && ... args
etc.
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