问题描述
具有多继承的空基本优化在msvc ++ 2010中似乎仍然被破坏。目前,它似乎只适用于派生自的第一个类型,所以如果你是从多个空基础派生,子类型最终有更多的字节
Empty base optimisation with multiple inheritance appears still to be broken in msvc++ 2010. Currently, it appears to only work for the first type derived from, so if you are deriving from multiple empty bases the child type ends up with more bytes (just useless padding!) than it needs.
显然,这已经是这种方式了一段时间:
Apparently it's been this way for some time: https://connect.microsoft.com/VisualStudio/feedback/details/100686/empty-member-optimization-not-working-properly
此链接标记为已关闭 - 不可修复。
This link is marked "closed - not to be fixed". Just wondering if anyone knew if there's anything happening with this "feature" these days??
推荐答案
broken是什么意思?那么,它不是标准符合吗?
What do you mean by "broken"? That, it is not Standard conformant?
标准不要求空类在从它们派生时具有零大小。实现可以选择优化这个或它可能根本不。
The Standard doesn't require empty classes to have zero size when deriving from them. An implementation may choose to optimize this or it may not at all.
这篇关于空基本优化MSVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!