AMDG On 01/21/2018 01:22 PM, Jean-Louis Leroy via Boost wrote:
Thanks for the comments.
I am still hesitating about some of the names and APIs. The library is pre-version 1.0.0, and it's the time to get things right.
I am still hesitating about the syntax for defining a method (overridern). I could easily support:
// no return type here // ---------V YOMM2_BEGIN(kick, (Dog& dog)) { return "bark"; } YOMM2_END;
It breaks the symmetry with YOMM2_DECLARE though.
I think I prefer having the return type present. (Does auto work?)
Now onto your points...
- I feel like it should be possible to get rid of YOMM2_END by moving the function body out-of-line or using a lambda or something.
Of course I would like to get rid of YOMM2_END, but I haven't yet found a way of doing that that also ensures that the body of the method can be inlined inside the wrapper that casts the virtual arguments. I trie with lambdas to back in 2014. Then maybe I've overlooked something, if you have an idea...
Can't you just rearrange it to: ... struct _YOMM2_SPEC { static RETURN_T body ARGS; }; ... register_spec<> init(); }} inline RETURN_T _YOMM2_NS::_YOMM2_SPEC::body ARGS There's nothing here that specifically prevents inlining. Whether the compiler actually inlines it is another question but that's already very compiler-specific and not guaranteed. Also, - "Each name that ... begins with an underscore followed by a capital letter is reserved to the implementation for any use" [global.names] - update_methods looks like it's totally thread-unsafe. You can probably get away with this if you only call it at the beginning of main, but it seems quite dangerous if you load or unload shared libraries. In Christ, Steven Watanabe