non virtual destructor
Hi,
I like you take on a simple state machine. When building with -Wnon-virtual-dtor you got some warning. I would add
virtual ~MooreMachine() noexcept = default;
to the MooreMachine template.
There is some reason I am missing why it is not there?
Adding a virtual destructor would waste resources, and there is no reason to have one, as the MooreMachine class (and derived classes) is NOT intended to be deleted through a pointer to it.
Or am I missing something?
If you have already a virtual method which resources are you wasting?
If you have already a virtual method which resources are you wasting?
At least a vtable entry, not sure what else. Building examples/api/moore_machine.cpp results in:
without virtual destructor:
# size -B -d moore_machine
text data bss dec hex filename
3277 768 584 4629 1215 moore_machine
with virtual destructor virtual ~MooreMachine() noexcept = default;
# size -B -d moore_machine
text data bss dec hex filename
3662 808 600 5070 13ce moore_machine