本文介绍了C ++父类排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以指定父类的调整?例如像(不编译):
Is it possible to specify alignment of parent class?for example something like (which does not compiled):
template<size_t n>
class Vector : public boost::array<double,n> __attribute__ ((aligned(16)))
{
感谢
好了,从我的意见收集,这是没有什么好办法去。我想我会只是坚持组合式/私人阵列的排列
well, from comments I gather this is no good way to go.I think I will just stick to composition/alignment of private array
推荐答案
我们不必要求在派生类中我们也不能对齐。我们之所以不需要的是,它是足够的请求队列为派生类,并要求调整派生类将导致对依赖于派生的基类的布局。
We don't need to request alignment on the derived class neither we can. The reason why we don't need is that it is enough to request alignment for the derived class, and that requesting alignment to the derived class will result on layout for the base class that depends on the derived.
class A : public C __attribute__ ((aligned(16)))
{
class B : public C __attribute__ ((aligned(8)))
{
这将是调整对C?
Which will be alignment for C?
这篇关于C ++父类排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!