Union vs. static_cast(void*)
I'm writing code and until now I was using structures like this: struct s{ enum Types { zero = 0, one, two }; unsigned int type; void* data; } I needed some generic structure to store data from different classes and I wanted to use it in std::vector, so that's reason why I can't use templates. What's better option: unions or void pointers? Void pointer allocates only as much space as I need, but c++ is strong typed language for some reason and casting everywhere I need to use those data is not the way c++ code should be designed. As I read, void pointers shouldn't be used unless there's no