Re: [Boost-users] Bind/Function: use reference arguments in template variadic functions
AMDG On 04/11/2013 01:57 PM, Yannick POTIN wrote:
<snip>
// A template variadic function... template
boost::function0<void> call_something(classes... c) { // ... here we are: return boost::bind(call_a,boost::ref(c...)); } <snip> ---------------------------------------------- After compilation, I get this output (watch the memory addresses): 0xbfc8f994::operator()(): 1 0xbfc8f990::operator()(): 2 0xbfc8f984::operator()(): 1 0xbfc8f984::operator()(): 2 I really don't know what happened (even if I can imagine). But references are just lost and this is not good.
So, here is my question: How can I make this working ?
The arguments of call_something are passed by value.
Try:
template
AMDG On 04/12/2013 03:41 AM, Yannick POTIN wrote:
template
boost::function0<void> call_something(classes&... c) Thank you, It actually allows me to use references in these functions. I just tried and g++ is waiting for only references but I need to use pointers and/or values too. There is a way to use mixed types in template variadic functions ?
For perfect forwarding use:
template
participants (2)
-
Steven Watanabe
-
Yannick POTIN