[Solved] Initializing std::map in an allocated struct fails on Windows


Your code looks like a weird mixture of C and C++. You are using malloc to allocate dynamic memory, which does not invoke C++ objects’ constructors. You should use new/delete (or even better, smart pointers) if you want to dynamically allocate memory.

Any idea why this would be?

The reason why your code doesn’t work is likely the fact that constructors are not invoked. I suggest reading a good C++ book (see The Definitive C++ Book Guide and List).

1

solved Initializing std::map in an allocated struct fails on Windows