Boost logo

Boost :

Subject: Re: [boost] Multi-methods and type switch
From: Camille GILLOT (k1000.jlo_at_[hidden])
Date: 2014-03-08 18:20:50


Le jeudi 6 mars 2014 06:51:45 Larry Evans a écrit :
> On 03/05/14 17:05, Camille GILLOT wrote:
> > Hello,
> >
> > SoC2014 page on trac mentions interest for an implementation of
> > type-switch
> > for C++.
>
> Could you please provide a link?
>
https://svn.boost.org/trac/boost/wiki/SoC2014

> > For now, I have implemented a toy library for open multiple dispatch. It
> > is
> > based on compressed dispatch tables. It still just supports single
> > inheritance and needs to attach integer tags to the dispatched class
> > hierarchy.
> Could you please provide source code? What are these integar tags
> used for?
>
Source code is at : https://github.com/cjgillot/rtti
The code is still poorly documented, please excuse it for now.

The integer tags are computed at load time for each registered class.

Each hierarchy owns a integer counter starting from 0. During static
initialization, each class in the hierarchy is given an id based on this
counter. (When I mention a class hierarchy, I mean a set of class sharing a
common base class)

> > Is there any interest for further development of this library ? What would
> > be the typical use cases ?
>
> I remember reading somewhere it could be used in a gaming application
> to code what happens when, for example, to opposing space warships
> do battle in space. Another toy use case it to decide what happens
> when two animals meet. (e.g. Dog chase cat. Cat eats mouse,)
>
> Using your library, how would you code the predator_prey.cpp example
> shown here:
>
> http://svn.boost.org/svn/boost/sandbox/variadic_templates/libs/composite_sto
> rage/sandbox/pack/predator_prey.cpp ?

https://github.com/cjgillot/rtti/blob/master/examples/predator_prey/predator_prey.cpp

Best regards,

Camille Gillot


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk