We have many native C ++ classes that serialize perfectly with boost :: serialization .
Now we want to change some of our member fields to a property so that we can use them in PropertyGrids . When we changed the class definition to ref class X , we got a huge amount of these compilation errors:
# 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
Here we have a lot of tiny classes, so it would be painful to write a wrapper for each of them!
Here is an example we used:
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; };
And here is the main test code:
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; }
Is it possible to use boost :: serialization with managed classes?
Edit:
If we change the class usage code to this:
... gps_position2^ g = gcnew gps_position2(24.567f); ...
then we get only 1 error:
error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' D:\path\to\Boost\boostw\boost\archive\detail\check.hpp 60
boost visual-c ++ c ++ - cli managed-c ++ boost-serialization
Sayyid
source share