samedi 28 novembre 2015

Is it legitimate to assign values to non-array objects with braces?

I discovered by accident that this works in the body of a program:(currently using g++ 5.2.0)

Vector4  pos;  
pos = {0.0, 1.1, 2.2, 3.3};  

The Vector4 class declares this data as named variables:

double  t, x, y, z;  

not as an array, and has no auto conversion cnstrs.

I guess memory storage is contiguous, so the compiler can figure out what to do. But is this legitimate usage, or can unallocated memory get used, or maybe some other gotchas possible?

Aucun commentaire:

Enregistrer un commentaire