Boost logo

Boost :

Subject: Re: [boost] [type_erasure] Downcasting is now possible
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2015-03-10 14:09:29


On 03/10/2015 11:24 AM, Mathias Gaunard wrote:
> How about something like this:
> any a;
> duck_visit(f, a);
> with 'f' a polymorphic function object constrained with SFINAE.

This isn't quite going to work be itself. SFINAE
doesn't actually matter as there's no way to make
duck_visit work without calling register_<F, int>()
somewhere in the program (assuming that 'a' holds an
int and F is the type of f).

> if f(a) is callable for the dynamic type of a, then call it, otherwise
> raise an exception.

It's a start. Of course, there's no reason to
limit it to one argument:

any a, b, c;
duck_visit(f, a, b, c);

As a matter of fact, I already have a function
named call which looks a lot like this, except
that it dispatches using the arguments' vtables.

The only real difficulty is how to integrate it
into my existing framework. In Boost.TypeErasure,
any is a class template. Handling the arguments
isn't a problem, but what is the return type of

In Christ,
Steven Watanabe

Boost list run by bdawes at, gregod at, cpdaniel at, john at