Boost logo

Boost Users :

Subject: Re: [Boost-users] binding to new
From: Stuart Dootson (stuart.dootson_at_[hidden])
Date: 2009-04-22 17:20:29


On Wed, Apr 22, 2009 at 10:13 PM, Noah Roberts <roberts.noah_at_[hidden]> wrote:
> I have a factory that returns an instance of a concrete under an
> abstraction.  It works by matching a "command" string to a command handler
> that is created and returned to the client.  It's basically a stack of
> regex->creator pairs.  The creator is a function that returns a pointer to
> the abstract type.
>
> I'd like to provide that function by binding to the new operator. Currently
> I have a static function in each concrete type that just calls new and I
> bind to it.  I can't think of what syntax I would use to bind to new and am
> inclined to think it impossible, but I thought I'd ask.

How about the new_ptr<T> function object in Boost.Lambda? (see
http://www.boost.org/doc/libs/1_38_0/doc/html/lambda/le_in_details.html#lambda.construction_and_destruction)

Stuart Dootson


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