Is it possible to use boost:serialization with Managed c++?

We have a native c++ class that is serialized perfectly using * boost::serialization*. Now we want to change some of its member fields to *property*, so we could use them in *PropertyGrids*. When we changed the class definiction to *ref class X*, we got a huge number 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 We have a lot of tiny classes here, so it would be a pain to write a wrapper for each of them! Here is the sample class 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 even possible to use *boost::serialization* with managed classes? p.s. 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

2010/10/31 سیّد امین میرزایی
We have a native c++ class that is serialized perfectly using boost::serialization.
Now we want to change some of its member fields to property, so we could use them in PropertyGrids. When we changed the class definiction to ref class X, we got a huge number 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
We have a lot of tiny classes here, so it would be a pain to write a wrapper for each of them!
Here is the sample class 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 even possible to use boost::serialization with managed classes?
p.s. 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
Unknown if they can work with managed classes, but do know for sure that Managed C++ has a *LOT* of template issues and in general does not work with 'real' C++ code.
participants (2)
-
OvermindDL1
-
سیّد امین میرزایی