Boost logo

Boost :

Subject: Re: [boost] yomm2 - open methods
From: Jean-Louis Leroy (jl_at_[hidden])
Date: 2018-01-19 21:59:02


OK I have been thinking about this in the meantime (hoping I
understood the problem, which you confirmed).

> But why exactly do you require it?
> a) You can do a (static|dynamic)_cast from the base to the
> derived type. Replace this with any_cast<Derived*>(&a) or
> static_cast<Derived*>(any_cast<void*>(&a)) for any.
> b) You can determine the dynamic type of the object with typeid.
> Replace this with typeid_of(a) for any.

Yes, I have a detail::virtual_traits<> that handles that sort of
things. For the time being is is undocumented, so I can experiment.

The other difficulty is the mechanism used to match declarations and
definitions. Methods can be overloaded (see example here:
https://github.com/jll63/yomm2/blob/master/examples/matrix.cpp#L51).
Method declarations declare (but do not define) an additional function
that has the same name and parameters as the dispatcher function, plus
an extra one. It returns the matching method, which is fed to
decltype(). That's how times(double, dense_matrix&) is matched with
times(double, virtual_<matrix&>) and times(diagonal_matrix&,
diagonal_matrix&) is matched with times(virtual_<matrix&>,
virtual_<matrix&>).

I will experiment during the weekend but there is some hope.


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