C++ sizeof wrapper class

邮差的信 提交于 2019-12-01 16:01:37

No, it might be more than sizeof(T) due to padding.

Seth Carnegie

I don't think it explicitly guarantees it, but I don't think it would ever be different.

I think C++ should guarantee sizeof(A) == sizeof(T).

Consider bellow situation, C++ should make it works just like in C:

A a[10];
T t[10];

A * ap = (A *) t;
T * tp = (T *) a;

memcpy(ap, tp, sizeof(*ap));
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!