Boost logo

Boost Users :

Subject: Re: [Boost-users] Using boost to eliminate an ugly facade function
From: Igor R (boost.lists_at_[hidden])
Date: 2012-08-29 14:50:59


> CCompany Company;
>
> CProcessor Processor;
>
> // Compiler error: the signal sends an instance of CPerson,
> // not the result of CPerson::GetAge(). Too bad because
> // CProcessor does not have know about CPerson
> //
> // Company.BossHired.connect(
> // boost::bind(&CProcessor::f, &Processor, _1));
>
> // So we use an ugly facade instead
> Company.BossHired.connect(
> boost::bind(ProcessorFacade, boost::ref(Processor), _1));

Although this is not an answer to your question, but if you have c++11
compiler, you can make a lambda:
        Company.BossHired.connect([&Processor](const CPerson& Person) {
Processor.f(Person.GetAge()); });


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