<div dir="ltr">We have a native c++ class that is serialized perfectly using <b>boost::serialization</b>.<div class="gmail_quote"><div dir="ltr"><div> <p>Now we want to change some of its member fields to <b>property</b>, so we could use them in <b>PropertyGrids</b>. When we changed the class definiction to <b>ref class X</b>, we got a huge number of these compilation errors:</p> <p style="background-color: rgb(204, 204, 204);">#1:<font size="2"> <code style="font-family: courier new,monospace;">error C2893: Failed to specialize function template 'boost::archive::text_oarchive &boost::archive::detail::interface_oarchive<Archive>::operator <<(T &)' d:\someAddress\someFile.cpp 58</code></font></p> <p style="background-color: rgb(204, 204, 204);">#2: <code style="font-family: courier new,monospace;">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</code></p> <p>We have a lot of tiny classes here, so it would be a pain to write a wrapper for each of them!</p> <p>Here is the sample class we used:</p> <pre><code><font style="font-family: courier new,monospace; color: rgb(0, 0, 153);" size="2"><span>ref</span><span> </span><span>class</span><span> gps_position2<br> </span><span>{</span><span><br></span><span>public</span><span>:</span><span><br> </span><span>template</span><span><</span><span>class</span><span> </span><span>Archive</span><span>></span><span><br> </span><span>void</span><span> serialize</span><span>(</span><span>Archive</span><span> </span><span>&</span><span> ar</span><span>,</span><span> </span><span>const</span><span> </span><span>unsigned</span><span> </span><span>int</span><span> version</span><span>)</span><span><br> </span><span>{</span><span><br> ar </span><span>&</span><span> seconds</span><span>;</span><span><br> </span><span>}</span><span><br> </span><span>public</span><span>:</span><span><br> gps_position</span><span>(){};</span><span><br> gps_position</span><span>(</span><span>float</span><span> s</span><span>)</span><span><br> </span><span>{</span><span><br> </span><span>this</span><span>-></span><span>seconds </span><span>=</span><span> s</span><span>;</span><span><br> </span><span>}</span><span><br><br> property </span><span>float</span><span> seconds</span><span>;</span><span><br></span><span>};</span></font><span><br> </span></code></pre> <p>And here is the main test code:</p> <pre><code><font style="font-family: courier new,monospace; color: rgb(0, 0, 153);" size="2"><span>int</span><span> main</span><span>()</span><span><br> </span><span>{</span><span><br> std</span><span>::</span><span>ofstream ofs</span><span>(</span><span>"out.txt"</span><span>);</span><span><br> <br> gps_position2 g</span><span>(</span><span>24.567f</span><span>);</span><span><br><br> </span><span>// save data to archive</span><span><br> </span><span>{</span><span><br> boost</span><span>::</span><span>archive</span><span>::</span><span>text_oarchive oa</span><span>(</span><span>ofs</span><span>);</span><span><br> </span><span>// write class instance to archive</span><span><br> oa </span><span><<</span><span> g</span><span>;</span><span><br> </span><span>}</span><span><br> </span><span>// ................</span><span><br> </span><span>return</span><span> </span><span>0</span><span>;</span><span><br> </span><span>}</span></font><span><br></span></code></pre> <p>Is it even possible to use <b>boost::serialization</b> with managed classes?</p> </div></div> <br>p.s. If we change the class usage code to this: <pre style="font-family: arial black,sans-serif;" class="prettyprint"><font size="2"><code><font style="font-family: courier new,monospace;" size="2"><span class="pln"> </span></font><font style="font-family: courier new,monospace;" size="2"><span class="pun">...</span><span class="pln"><br> gps_position2</span><span class="pun">^</span><span class="pln"> g </span><span class="pun">=</span><span class="pln"> gcnew gps_position2</span><span class="pun">(</span><span class="lit">24.567f</span><span class="pun">);</span><span class="pln"><br> </span><span class="pun">...</span></font><span class="pln"><br></span></code></font></pre> <p>then we get only 1 error:</p> <p style="font-family: courier new,monospace;"><font size="1"><code><font style="font-family: courier new,monospace;" size="2">e</font><font style="font-family: courier new,monospace;" size="2">rror C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' D:\path\to\Boost\boostw\boost\archive\detail\check.hpp 6</font><font style="font-family: courier new,monospace;" size="2">0</font></code></font></p></div></div>