2

This is the code:

#include <glm/glm.hpp>

struct AABB
{
    union {
        struct { glm::vec3 pMin, pMax; };
        struct { float x0, y0, z0, x1, y1, z1; };
    };
};

Try it.

I'm guessing it's not allowed because glm::vec3 has a contructor. What's the alternative?

There is this similar question but it's not the same: constructor not allowed in anonymous aggregate, string in struct

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
tuket
  • 3,232
  • 1
  • 26
  • 41
  • one solution proposed in the related post is to use pointers to types/classes instead of the concrete type – Nikos M. Oct 31 '20 at 18:18
  • 4
    Possibly off topic but it looks like you're trying to type-pun through a union. That will generally result in undefined behaviour in C++. – G.M. Oct 31 '20 at 18:20
  • @G.M Oh, true, I forgot about that :/ – tuket Oct 31 '20 at 18:33

0 Answers0