0

I.e. can I do this:

XMMATRIX dxMat;
Matrix myMat;
std::memcpy(&myMat, &dxMat, sizeof(XMMATRIX));
std::memcpy(&dxMat, &myMat, sizeof(XMMATRIX));

Matrix is my own class which contains 16 contiguous float variables. Also can I do the same with my vector class (4 floats) and XMVECTOR?

Edit: In other words, is XMMATRIX a POD?

NPS
  • 6,003
  • 11
  • 53
  • 90
  • Depends on whether your classes are PODs or not. – Mat Jan 04 '14 at 13:10
  • @Mat I've already written - they're composed of 16 contiguous floats. And nothing more. Yes, they're PODs. Actually, I could also state my question this way - are XMMATRIX's PODs? – NPS Jan 04 '14 at 20:30
  • 2
    That's not what you said. You said your class contains 16 contiguous floats. You didn't say if it contained anything else (perhaps mixed private and public), had virtual functions, had non-trivial constructor and copy operators, ... http://stackoverflow.com/questions/4178175/what-are-aggregates-and-pods-and-how-why-are-they-special?lq=1 – Mat Jan 05 '14 at 06:46
  • You should certainly use the assignment operator rather than memcpy(), regardless of what the class contains. That gives the authors of the class the opportunity to define the correct semantics himself. – user207421 Jan 05 '14 at 20:32
  • Ok, but I asked if I **could** do that. If I needed to for any reason. – NPS Jan 06 '14 at 19:55

0 Answers0