Boost logo

Boost :

From: alnsn_at_[hidden]
Date: 2004-06-25 13:07:44

Dr. Franz Fehringer wrote:
> On (Boost Corner) the first article is
> I/O System: dynamic_any campaign by Alexander Nasonov.
> Is dynamic_any really scheduled for inclusion in boost (1.32 say)?
Not really. It's not even scheduled for review yet.

Actually, I'm working on multiple dispatch in the library. This means
that call/call_ex scheme will be replaced with something new. My current
favorite is nested definition class (like spirit::grammar's definition).
Implementation for a function with one anyT argument is easy and done
already (I should think it over, though).
Multi-methods come into play when there are more then one anyT in
function's signature.

My current vision is based on proposal N1529:

 Draft proposal for adding Multimethods to C++
 Document number: WG21/N1529 = J16/03-0112
 Author: Julian Smith

// Example is taken from N1529

struct shape {...};
struct square : shape {...};
struct triangle : shape {...};

bool overlap( virtual shape& a, virtual shape& b);
bool overlap( static square& a, static triangle& b) {...}
bool overlap( static triangle& a, static square& b) {...}
bool overlap( static shape& a, static square& b) {...}
bool overlap( static square& a, static shape& b) {...}

I'm trying to be as close to this as possible. Compare:

struct overlap : function<overlap, bool(anyT&, anyT&)>
  struct definition
    bool operator()(overload_id<0>, square& a, triangle& b) const {...}
    bool operator()(overload_id<1>, triangle& a, square& b) const {...}
    bool operator()(overload_id<2>, shape& a, square& b) const {...}
    bool operator()(overload_id<3>, square& a, shape& b) const {...}

    definition(overlap const& ) {}

    BOOST_STATIC_CONSTAT(int, max_overload_id = 3);

New syntax for virtual arguments isn't required because anyT arguments
imply virtuality. In order to enumerate all arguments' combinations
at compile-time, overload_id<N> is introduced.
I hope to finish it within a couple of months.

Alexander Nasonov

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