STL within headers of third party library in UE5

Hi, I’m wondering this myself. I think I have an answer though.

By my understanding of C++, as soon as a class works with an STL/std object in any way, even holding it as a private field, then it’s very important to ensure every bit of compiled code which involves that class at all is using the exact same version of the standard library. The best way to achieve this is to compile all code in your project with the same compiler, compiler version, and compiler settings.

Unreal is presumably compiling all modules the same way, and certainly with the same compiler, so within an Unreal project this should not be a problem. However, if a third-party library uses the STL and hands you a pre-compiled library (DLL or LIB file) with headers, then you will most likely have problems using this library.

Side node, one way to sidestep this arduous requirement would be for the library to store the STL object as a void* field, allocating and deallocating it entirely within its own DLL. This design pattern is known as Pointer to Implementation, or PImpl.