I'm trying to export a C++ class out of a DLL with stl members.
Here's my main class.
class MATHFUNCSDLL_API MyMathFuncsImpl
{
public:
std::vector<int> vi;
std::string getString();
void setString(std::string s);
private:
std::string s;
};
Using the methods works, but gives warnings on VS 2012 about std::string and std::vector not having a dll-interface. Now when I do this -
class MATHFUNCSDLL_API MyMathFuncs
{
public:
MyMathFuncs()
{
pImpl = new MyMathFuncsImpl();
}
std::string getString()
{
return pImpl->getString();
}
std::vector<int> getVector()
{
return pImpl->vi;
}
void setString(std::string news)
{
pImpl->setString(news);
}
private:
MyMathFuncsImpl* pImpl;
};
I get no warnings, and it also works. My question is this: does having an interface like this really solve the problem (stl members might be implemented differently across dll boundary), or is it just a trick to suppress compiler issues?