Boost logo

Boost :

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 <> 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
>>> impossible.
>> 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, gregod at, cpdaniel at, john at