Subject: Re: [boost] [any] Multimethod for boost::any and modified boost::any to fit multi method
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-02-13 10:54:08
Mathias Gaunard wrote:
> Andrey Semashev wrote:
>> Mathias Gaunard wrote:
>>> A while ago, I offered something like this
>>> any m = 0;
>>> apply_visitor<int, double, A>(f, m);
>>> or alternatively,
>>> apply_visitor(f, m); with f specifying all overloads in some
>>> compile-time reflection structure.
>>> unfortunately, it cannot be made constant-time because std::type_info
>> FWIW, I would be really interested in this feature even if it's not
>> constant time. May I hope it will appear in trunk one day?
> It can actually be made constant-time using the result of
> std::type_info::name for dispatching.
> That means, however, that you need to know as a compile-time string the
> names of the types to check for, and have implemented a compile-time
> name mangling algorithm (which is of course platform-specific).
That looks like too much of a burden for users, let alone the
portability issues. I think the implementation that provides the
interface you mentioned above would be more suitable, even if slower. I
don't think that people will often try to dispatch between hundreds or
even tens of types, where the difference would matter.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk