
I have zero experience using TypeErasure so what I am going to say here may miss the point entirely. A priori it's two different worlds because open methods suppose that there is an is-a relationship between the virtual parameters in the method declaration and the corresponding arguments in the method definitions (aka overrides or specializations). It also supposes that virtual parameters are polymorphic types. But wait! yomm2 supports virtual_<std::shared_ptr<Animal>> parameters in addition to virtual_<Animal&> and virtual_<Animal*> - and shared_ptrs are not polymorphic types (neither is Animal* in fact) so there is some flexibility here. Do you mean something like (inspired from my synopsis): using AnyAnimal = any< mpl::vector< ... > >; declare_method(string, kick, (virtual_<AnyAnimal>)); define_method(string, kick, (Dog* dog)) { return "bark"; } define_method(string, kick, (Bulldog* dog)) { return "bark and bite"; } ...or even (following Steven's Basic Usage example): using AnyCounter = any< mpl::vector< copy_constructible<>, typeid_<>, incrementable<>, ostreamable<> >
;
declare_method(string, describe, (virtual_<AnyCounter>)); define_method(string, describe, (int* num)) { return "it's an integer"; } define_method(string, describe, (double* dog)) { return "it's a double"; } If I'm off the mark maybe you can provide an example to illustrate your question? On Fri, Jan 19, 2018 at 3:27 PM Zach Laine via Boost <boost@lists.boost.org> wrote:
On Fri, Jan 19, 2018 at 1:24 PM, Steven Watanabe via Boost < boost@lists.boost.org> wrote:
AMDG
On 01/19/2018 11:23 AM, Jean-Louis Leroy via Boost wrote:
in 2013 I posted a proposal for an "open multi-methods" library, see here: https://lists.boost.org/Archives/boost/2013/07/205383.php Due to insufficient interest, I did not go forward with a formal submission, and I published my work on github, under the name yomm11.
I have now completely rewritten the library. The new version - yomm2 - is available here: https://github.com/jll63/yomm2 This iteration is much better because it does not require any modifications to classes involved in method dispatch, yet the speed of a method call with one virtual argument is within 15% of the equivalent virtual function call.
So, if it's fully non-intrusive, can it be made to work with boost::any or Boost.TypeErasure?
This was the first thing that occurred to me, too. A graceful way to do dynamic re-binding of erased types is something I want.
zach
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost