Subject: Re: [boost] [functional] [overloaded_function] polymorphic functions?
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2012-03-27 17:19:23
On Mar 14, 2012, at 6:33 PM, Dave Abrahams wrote:
> on Wed Mar 14 2012, Gordon Woodhull <gordon-AT-woodhull.com> wrote:
>>> If the type of o did not involve poly, then you could pass a reference
>>> to o to another translation unit where the definition of poly was not
>>> visible. In that other translation unit you could call it with an
>>> arbitrary type, which would have to instantiate poly::operator() without
>>> sight of its definition. Therefore, I conclude that this is clearly
>> I had neglected the fact that overloaded_function does type erasure
>> (duh). I guess this would only be possible if the polymorphic
>> result_of (or equivalent) is passed to overloaded_function. Probably
>> not worth it.
> I think Lorenzo's assessment ("not possible") is more accurate.
Right, on further thought, I think this would require templated virtual methods, which are impossible as far as I know. That might be the most succinct way of putting it.
Of course, this still wouldn't preclude a non-type-erased polymorphic function overloader.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk