|
|
|
|
|
by mehrdadn
2902 days ago
|
|
I'm just saying do conditional compilation instead of virtual dispatch, since you generally shouldn't really need both the test and production implementations to run inside the same program. So if you have reason to require // widget.h
class Widget { virtual void throb(); };
// widget.cc
class WidgetImpl : public Widget { void throb() { ... } };
class WidgetTest : public Widget { void throb() { ... } };
then, instead of that, just do // widget.h
class Widget { void throb(); };
// widget.cc
void Widget::throb() { ... }
// widget.test.cc
void Widget::throb() { ... }
where you only compile widget.cc for the production build, and only compile widget.test.cc for the test build.Feel free to post a more specific example and I can take a stab at seeing if I can make this transformation to it (or why it might not be possible, if you think it's not). |
|
Essentially, it was easier to write a compiler / linker optimization, than change the source code. On the bright side, everyone wins!