I saw that compiler warns when dll-exposed class contains STL containers as their member or function argument, since STL is not guaranteed to generate same binaries over various compilers.
However, if those unsafety-ness comes from 'the implementation is not always same', then can we assume that our own template classes, which never depends on STL, can safely cross dll boundaries?
Like if we have below template class,
// my_vector.hxx
template<typename Ty>
class my_vector {
// Some functions...
private:
Ty_* _ptr; // Internally, contiguous memory will be allocated.
size_t _size;
size_t _capacity;
}
And then we utilize this two different dlls,
// A.dll, A.cpp
extern "C" void* create_A() {
return new my_vector<int>{}; // instantiates my_vector<int> locally.
}
// B.dll, B.cpp
extern "C" void use_B(void* pv) {
(*(my_vector<int>*)pv).some_fn(); // instantiates my_vector<int> locally either.
}
And then an executable refers two dlls,
// foo.exe
void bar(){
auto data = create_A(); // from A.dll
use_B(data); // into B.dll
}
Then can we assume that above example works correctly in general use-cases? unlike from STL utilization between multiple DLLs?