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.
On Wed, Apr 22, 2009 at 10:13 PM, Noah Roberts
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#lamb...) Stuart Dootson
participants (2)
-
Noah Roberts
-
Stuart Dootson