|
Boost Users : |
Subject: Re: [Boost-users] [Statechart] Passing referencetocreate_processor()
From: Andreas Huber (ahd6974-spamboostorgtrap_at_[hidden])
Date: 2009-04-23 18:24:14
Hi Peter
Thanks for looking at this!
>> I must admit I don't currently see why this happens, I'll probably have
>> to produce a minimal repro and ask bind experts for help.
>
> It happens because ultimately you produce a bind expression such as
>
> boost::bind( pImpl, this, ..., boost::ref( value ) )
>
> and the ref is interpreted by bind as a reference to 'value'. But your
> Arg1 remains a reference_wrapper. You'll probably need to convert ArgN
> parameters that are of the form reference_wrapper<X> to X& before
> instantiating create_processor_implN.
Ok, lets see whether I understand this correctly:
#include <boost/noncopyable.hpp>
#include <boost/bind.hpp>
class Object : public boost::noncopyable {};
void func1(Object &) {}
void func2(boost::reference_wrapper<Object>) {}
int main()
{
Object value;
boost::bind(&func1, boost::ref(value))(); // 1: compiles
boost::bind(&func2, boost::ref(value))(); // 2: doesn't
return 0;
}
2 doesn't compile because bind internally assumes that the target function
accepts a T & parameter for each reference_wrapper<T> argument, correct?
If so, then I guess I should use boost::unwrap_reference<Arg1>::type instead
of Arg1 to instantiate create_processor_impl1.
Thanks & Regards,
-- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net