What's the c++'s default assign operation behavior?
eg, it pazzle me:
struct A {
// some fileds...
char buf[SIZE];
};
A a;
a = a;
Through A's filds buf, it looks like probably that the default assign
opertion will call something like memcpy to assign an object X to Y, so
what if assign an object to itself and there are no explict assign
opertion defined, like a = a; above.
memcpy manual page:
The memcpy() function copies n bytes from memory area src to memory area
dest.
The memory areas must not overlap. Use memmove(3) if the memory areas do
overlap.
If use memcpy, there may some undefined behavior occur.
So, what's the default assign operation behavior in C++ object?
No comments:
Post a Comment