A
Alf P. Steinbach
* frs:
Re-design so that you avoid polymorphic delete; that's _all_ you need to do,
and you need to do that anyway if you don't have any virtual functions.
Forget about taking control. You don't need more detailed control. You need
instead to understand that the built-in mechanism in C++ is just about the
only one that makes sense, and that the goal is therefore to work with the
langauge so as to use that built-in mechanism, not to replace it (which will
be less efficient) or "improve" it (which will be incorrect and possibly UB).
Having said that, however, it may be that you need a few ideas for the
re-design. And one such idea that I think you'll benefit from is the
flyweight pattern. It tackles the problem of having many small objects.
but I was was indeed looking for avoidance of virtual functions at all.
Re-design so that you avoid polymorphic delete; that's _all_ you need to do,
and you need to do that anyway if you don't have any virtual functions.
Forget about taking control. You don't need more detailed control. You need
instead to understand that the built-in mechanism in C++ is just about the
only one that makes sense, and that the goal is therefore to work with the
langauge so as to use that built-in mechanism, not to replace it (which will
be less efficient) or "improve" it (which will be incorrect and possibly UB).
Having said that, however, it may be that you need a few ideas for the
re-design. And one such idea that I think you'll benefit from is the
flyweight pattern. It tackles the problem of having many small objects.