4 ms·
Well if this is an improvement or not depends on the use case. E.g. std::function does exactly this. What it achieves is exactly erasing the type (conforming t
by aptxkid 5y ago
Well if this is an improvement or not depends on the use case. E.g. std::function does exactly this.
What it achieves is exactly erasing the type (conforming to an affordance). The cost is definitely there. You pay vtable lookup when using std::function.
- nly 5y agoYou're not wrong in any way, but interestingly, last I looked, common implementations of std::function didn't use virtual under the covers. Instead they re-implement something like the vtable to avoid unwanted extras, like RTTI, bloating your app size