Boost logo

Boost :

Subject: Re: [boost] yomm2 - open methods
From: Jean-Louis Leroy (jl_at_[hidden])
Date: 2018-01-21 00:54:41

OK after adding a bit of flexibility, and then taking advantage of it,
I could make this work:

using Any = any<mpl::vector<copy_constructible<>, typeid_<>, relaxed> >;

declare_method(string, type, (virtual_<Any>));

begin_method(string, type, (int value)) {
    return "int " + std::to_string(value);
} end_method;

register_class(int, Any); // I guess...

struct Animal {};

    Any x(10);
    BOOST_TEST(type(x) == "int 10");

(complete code at here:

I feel a bit uneasy though.

If yomm2 ever becomes a part of Boost, I do see the value of making it
play ball with other Boost libraries.

On the other of my major sources of inspiration is the
paper by Pirkelbauer, Solodkyy and Stroustrup (the other being CLOS).
I try to emulate the proposed syntax and functionality that they
describe, in the hope that people get to try open methods, start
liking them and, eventually, they become part of the language.

So this is quite a stretch. That being said, I already drift from the
paper by supporting std::shared_ptr virtual parameters...and my Matrix
example shows that open methods without support for smart pointers
would miss some important use cases.

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