Make MFPRenderer
inherit Renderer
instead of using composition
#13
Labels
enhancement
New feature or request
MFPRenderer
inherit Renderer
instead of using composition
#13
This would be much more elegant and less error-prone if we didn't have to write
T1 function(T2 arg) { return renderer.function(arg); }
inMFPRenderer
for each method ofRenderer
we want to expose.After a bunch of failed attempts, it seems that it is not possible to achieve this using inheritance in C++.
I tried :
and use a specialized version
MFPRenderer<noteData, commandData, commandKey>
with only explicit specializations of methods which required modifications.I also tried :
In both cases, we inherit from a class template we never fully explicitly specialize or instantiate, so all the functions that are not specialized with the concrete types are undefined, and although compilation succeeds with emscripten we end up with
... is not a function
errors in the JS code.I tried to create dummy instances of
Renderer<noteData, commandData, commandKey>
in the code (as static and local MFPRenderer variables), but this didn't help, maybe because of some compiler optimizations, or maybe because I don't grasp the issue very well ...The only way to get inheritance to work (in both cases), is to write stuff like this for every public member
in the first case and
in the second case which is as verbose and error-prone as the composition based design.
So, if anyone comes up with a better solution, I'm all ears.
Meanwhile, I'll stick with the composition based design.
The text was updated successfully, but these errors were encountered: