![]() |
Boost : |
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2025-05-06 23:25:11
AMDG
On 5/6/25 4:52 PM, Jean-Louis Leroy via Boost wrote:
> Hi Steven,
>
>>> I tried since you last suggested this. Couldn't make it work. The macro
>>> generates something like:
>>>
>>> auto poke(std::ostream& a, virtual_ptr<Animal> b) -> void {
>>> method<poke_method(std::ostream& a, virtual_ptr<Animal> b)>::fn(a, b);
>>> }
>>>
>>> There is no way to peel off the `void` from the signature with the syntax you
>>> suggest.
>>>
>>
>> It doesn't need to be peeled off by the macro. You're only using it
>> as a template parameter, so you can just pass the whole signature
>> as a function type.
>
> What about the `void` after the arrow?
>
You mean like this?
BOOST_OPENMETHOD(poke, (std::ostream& a, virtual_ptr<Animal> b) -> void)
That's possible. You can get a function type by prepending auto, which
can be used for most template parameters and (with some metaprogramming)
the return type.
> It might work if we could define a function using a function type:
>
> using Signature = void(std::ostream& a, virtual_ptr<Animal> b);
>
> Signature poke {
> method<poke_method(std::ostream& a, virtual_ptr<Animal> b)>::fn(a, b);
> }
>
> Alas this is illegal. Not sure why. Probably because of the parameter names...
>
Right. The function type trick works for everything except the actual
function definition (where you need the parameter names).
> For what it's worth, here is the syntax that I would like:
>
> BOOST_OPENMETHOD(void poke(std::ostream&,virtual_ptr<Animal>)) { ... }
>
Would be nice. Too bad it that leaves no way to get poke as a usable
identifier.
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk