Nothing has changed with regards passing C++ objects across DLL boundaries. That is still not allowed for the same reason as before. The module on the other side of the boundary may have a different definition of the class.
The fact that &s[0]
is a valid modifiable pointer to character array is not really relevant. Because a std::basic_string
is a lot more than just an array of characters.
Remember that each implementation of std::basic_string
can have different internal storage. Can have a different implementation for operator[]
. Can be allocated off a different heap. And so on.
I think it is safe to assume that it will never be valid to pass C++ objects across general DLL boundaries. It is only viable if you guarantee that both sides of the boundary are linked against the same runtime instance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…