boost::serializationを使用して完全にシリアル化された多くのネイティブ C++ クラスがあります。
次に、メンバー フィールドの一部をpropertyに変更して、それらをPropertyGridsで使用できるようにします。クラス定義をref class Xに変更すると、膨大な数のコンパイル エラーが発生しました。
#1:
error C2893: Failed to specialize function template 'boost::archive::text_oarchive &boost::archive::detail::interface_oarchive<Archive>::operator <<(T &)' d:\someAddress\someFile.cpp 58
#2:
error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::_Smanip<_Arg> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'boost::archive::text_oarchive' d:\someAddress\someFile.cpp 58
ここには小さなクラスがたくさんあるので、それぞれのラッパーを書くのは面倒です!
使用したサンプル クラスは次のとおりです。
ref class gps_position2
{
public:
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & seconds;
}
public:
gps_position(){};
gps_position(float s)
{
this->seconds = s;
}
property float seconds;
};
そして、ここにメインのテストコードがあります:
int main()
{
std::ofstream ofs("out.txt");
gps_position2 g(24.567f);
// save data to archive
{
boost::archive::text_oarchive oa(ofs);
// write class instance to archive
oa << g;
}
// ................
return 0;
}
マネージド クラスでboost::serializationを使用することさえ可能ですか?
編集:
クラス使用コードを次のように変更すると:
...
gps_position2^ g = gcnew gps_position2(24.567f);
...
次に、エラーが 1 つだけ表示されます。
error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' D:\path\to\Boost\boostw\boost\archive\detail\check.hpp 60