Do the padding bytes of a POD type get copied?

后端 未结 4 1144
忘了有多久
忘了有多久 2021-01-03 17:21

Suppose I have a POD type like this:

struct A {
    char a;
    int b;
};

On my system, sizeof(A) == 8, even though size

4条回答
  •  我在风中等你
    2021-01-03 17:49

    The implicitly-defined copy/move constructor for a non-union class X performs a memberwise copy/move of its bases and members.

    12.8/15 [class.copy] in N4141

    The bit pattern in the padding bytes is thus allowed to differ.

提交回复
热议问题