2
プライベート構造体のベクトルを含むクラスA(エクスポートしたい)があります。コードをコンパイルするときに私は警告C4251(http://msdn.microsoft.com/en-us/library/esew7y1w.aspx)を持っています。この警告を防ぐために、私は明示的なインスタンス化を行いました。 VS2008では、これは何の問題もなくコンパイルが、VS2010で、私はエラーを次ていますプライベート構造体のベクトルを含むクラスをエクスポートする方法
エラーC2252:
があります:テンプレートの明示的なインスタンスを唯一の名前空間スコープで
(http://msdn.microsoft.com/en-us/library/4ds5s2s4(v=vs.100).aspxエラーC2252)を発生することがありますベクトルを使ってクラスをエクスポートし、構造体を非公開にする方法はありますか?
class __declspec(dllexport) A
{
public:
A();
~A();
private:
struct StructData
{
unsigned int b_;
};
#if defined(WIN32) && !defined(__GNUC__)
template class __declspec(dllexport) std::allocator<StructData>; // explicit instantiation needed to prevent warning C4251
template class __declspec(dllexport) std::vector<StructData, std::allocator<StructData> >; // explicit instantiation needed to prevent warning C4251
#endif
std::vector<StructData> StructDataVector_;
};