I have this structure which I've been using without bugs so far:
union Vector3f
{
struct{ float x,y,z ; } ;
float elts[3];
} ;
There are a couple of overloaded constructors, but I left the copy constructor and assignment operator=
to their default implementations.
Vector3f a,b ;
b=a; //works as expected, with x,y,z copied over from a to b
It just occurred to me that default memberwise assignment should execute b.elts=a.elts
, which since elts
is a pointer type, should result in b.elts
incorrectly pointing to a.elts
.
However, explicitly attempting b.elts=a.elts
fails with compilation error
Array type float[3] is not assignable
Is this something to worry about? Is my code ok or should I explicitly write a copy ctor and assignment operator=
?