Subject: Re: [boost] Phoenix3 port to proto complete
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-07-23 21:28:21
On 7/24/10 5:31 AM, Ahmed Charles wrote:
> std::bind and boost::bind are both monomorphic. phoenix::bind is
> Would you (or anyone else) mind explaining polymorphic vs monomorphic in
> this context? Or point to an explanation?
When you bind a function-pointer or member-function pointer, you are
passing in an exact signature with exact argument and return types
(e.g. int(*)(int)). OTOH, when you bind a function-object, the bound
function object may have various overloads or templates that deal with
different argument and return types. However, without decltype, we
can't deduce the return type from argument types. The original protocol
was to require function objects to have a typedef result_type. But this
forces them to be monomorphic since you can't choose the return type
depending on the argument types that are actually passed. The new
result_of protocol fixes this.
Phoenix had polymorphic bind from day one, albeit with a different
"resulf" protocol that predates "result_of". Actually, if you look
at the result_of documentation, Phoenix is one of the inspirations.
Phoenix3 now uses the standard result_of protocol.
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk