|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-02-14 16:36:49
Meryl Silverburgh wrote:
> How can I use boost:bind library to bind to constructor of a class.
>
> Right now, I have code like this:
> class build
> {
> public:
>
> Rect* operator()(string& str)
> {
> return new Rect(str);
> }
>
> };
>
> void TestBlockData::buildRectList( vector<string>& inputs, RectList&
> bdl) {
>
> transform(inputs.begin(), inputs.end(), bdl.begin(), build());
> }
>
> I wonder if I can get rid of the whole "build class" by using
> boost::bind library.
No, you can't; boost::bind can only adapt existing function objects into new
function objects, but as a general rule it can't create function objects
from scratch. The Lambda library has new_ptr<Rect>() that may work for you,
though:
http://www.boost.org/doc/html/lambda/le_in_details.html#lambda.construction_and_destruction
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