Boost C++ Libraries: Ticket #2912: implementation of std::bitset serialization https://svn.boost.org/trac10/ticket/2912 <p> I have attached an implementation of std::bitset serialization and the associated unit test for consideration for future addition to the serialization library. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2912 Trac 1.4.3 kfriddile@… Sat, 04 Apr 2009 00:32:21 GMT attachment set https://svn.boost.org/trac10/ticket/2912 https://svn.boost.org/trac10/ticket/2912 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bitset.hpp</span> </li> </ul> <p> serialization support for std::bitset </p> Ticket kfriddile@… Sat, 04 Apr 2009 00:32:59 GMT attachment set https://svn.boost.org/trac10/ticket/2912 https://svn.boost.org/trac10/ticket/2912 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test_bitset.cpp</span> </li> </ul> <p> unit test for std::bitset serialization </p> Ticket Robert Ramey Sat, 04 Apr 2009 04:21:23 GMT status changed https://svn.boost.org/trac10/ticket/2912#comment:1 https://svn.boost.org/trac10/ticket/2912#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Robert Ramey Thu, 16 Apr 2009 16:39:07 GMT <link>https://svn.boost.org/trac10/ticket/2912#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2912#comment:2</guid> <description> <p> When I try and compile the test - Get compile errors with MSVC 7.1 </p> <pre class="wiki">Compiling... test_bitset.cpp c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(39) : error C2783: 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; std::bitset&lt;_Bits&gt;::to_string(void) const' : could not deduce template argument for '_Elem' with [ _Bits=8 ] C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\bitset(282) : see declaration of 'std::bitset&lt;_Bits&gt;::to_string' with [ _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_free.hpp(45) : see reference to function template instantiation 'void std::save&lt;Archive,8&gt;(Archive &amp;,const std::bitset&lt;_Bits&gt; &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_free.hpp(41) : while compiling class-template member function 'void boost::serialization::free_saver&lt;Archive,T&gt;::invoke(Archive &amp;,const T &amp;,const unsigned int)' with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_free.hpp(74) : see reference to class template instantiation 'boost::serialization::free_saver&lt;Archive,T&gt;' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(59) : see reference to function template instantiation 'void boost::serialization::split_free&lt;Archive,std::bitset&lt;_Bits&gt;&gt;(Archive &amp;,T &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, _Bits=8, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\serialization.hpp(133) : see reference to function template instantiation 'void std::serialize&lt;Archive,8&gt;(Archive &amp;,std::bitset&lt;_Bits&gt; &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\de tail\oserializer.hpp(148) : see reference to function template instantiation 'void boost::serialization::serialize_adl&lt;Archive,T&gt;(Archive &amp;,T &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\extended_type_info_typeid.hpp(74) : while compiling class-template member function 'void boost::archive::detail::oserializer&lt;Archive,T&gt;::save_object_data(boost::archive::detail::basic_oarchive &amp;,const void *) const' with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(236) : see reference to class template instantiation 'boost::archive::detail::oserializer&lt;Archive,T&gt;' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(230) : while compiling class-template member function 'void boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;::save_standard::invoke(Archive &amp;,const T &amp;)' with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(294) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;::save_standard' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(282) : while compiling class-template member function 'void boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;::invoke(Archive &amp;,const T &amp;)' with [ Archive=boost::archiv e::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(506) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save&lt;Archive,T&gt;(Archive &amp;,const T &amp;)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\basic_text_oarchive.hpp(75) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive&lt;Archive&gt;::save_override&lt;const T&gt;(const T &amp;,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\interface_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive&lt;Archive&gt;::save_override&lt;const T&gt;(const T &amp;,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\nvp.hpp(78) : see reference to function template instantiation 'Archive &amp;boost::archive::detail::interface_oarchive&lt;Archive&gt;::operator &lt;&lt;&lt;const T&gt;(const T &amp;)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\access.hpp(93) : see reference to function template instantiation 'void boost::serialization::nvp&lt;T&gt;::save&lt;Archive&gt; (Archivex &amp;,const unsigned int) const' being compiled with [ T=std::bitset&lt;8&gt;, Archive=boost::archive::text_oarchive, Archivex=boost::archive::text_oarchive ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_member.hpp(43) : see reference to function template instantiation 'void boost::serialization::access::member_save&lt;Archive,const T&gt;(Archive &amp;,const T &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_member.hpp(42) : while compiling class-template member function 'void boost::serialization::detail::member_saver&lt;Archive,T&gt;::invoke(Archive &amp;,const T &amp;,const unsigned int)' with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_member.hpp(69) : see reference to class template instantiation 'boost::serialization::detail::member_saver&lt;Archive,T&gt;' being compiled with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\nvp.hpp(88) : see reference to function template instantiation 'void boost::serialization::split_member&lt;Archive,boost::serialization::nvp&lt;T&gt;&gt;(Archive &amp;,boost::serialization::nvp&lt;T&gt; &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\access.hpp(109) : see reference to function template instantiation 'void boost::serialization::nvp&lt;T&gt;::serialize&lt;Archive&gt;(Archive &amp;,const unsigned int)' being compiled with [ T=std::bitset&lt;8&gt;, Archive=boost::archive::text_oarchive ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\serialization.hpp(74) : see reference to function template instantiation 'void boost::serialization::access::serialize&lt;Archive,T&gt;(Archive &amp;,T &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\serialization.hpp(133) : see reference to function template instantiation 'void boost::serialization::serialize&lt;Archive,T&gt;(Archive &amp;,T &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(224) : see reference to function template instantiation 'void boost::serialization::serialize_adl&lt;Archive,T&gt;(Archive &amp;,T &amp;,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(217) : while compiling class-template member function 'void boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;::save_only::invoke(Archive &amp;,const boost::serialization::nvp&lt;std::bitset&lt;_Bits&gt;&gt; &amp;)' with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt;, _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(294) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;::save_only' being compiled with [ Archi ve=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(282) : while compiling class-template member function 'void boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;::invoke(Archive &amp;,const boost::serialization::nvp&lt;std::bitset&lt;_Bits&gt;&gt; &amp;)' with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt;, _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(506) : see reference to class template instantiation 'boost::archive::detail::save_non_pointer_type&lt;Archive,T&gt;' being compiled with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save&lt;Archive,T&gt;(Archive &amp;,T &amp;)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\basic_text_oarchive.hpp(75) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive&lt;Archive&gt;::save_override&lt;T&gt;(T &amp;,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\interface_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive&lt;Archive&gt;::save_override&lt;T&gt;(T &amp;,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp&lt;std::bitset&lt;8&gt;&gt; ] \BoostRelease\libs\serialization\test\test_bitset.cpp(47) : see reference to function template instantiation 'Archive &amp;boost::archive::detail::interface_oarchive&lt;Archive&gt;::operator &lt;&lt;&lt;const boost::serialization::nvp&lt;T&gt;&gt;(const boost::serialization::nvp&lt;T&gt; &amp;)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset&lt;8&gt; ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(39) : error C2783: 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; std::bitset&lt;_Bits&gt;::to_string(void) const' : could not deduce template argument for '_Tr' with [ _Bits=8 ] C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\bitset(282) : see declaration of 'std::bitset&lt;_Bits&gt;::to_string' with [ _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(39) : error C2783: 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; std::bitset&lt;_Bits&gt;::to_string(void) const' : could not deduce template argument for '_Alloc' with [ _Bits=8 ] C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\bitset(282) : see declaration of 'std::bitset&lt;_Bits&gt;::to_string' with [ _Bits=8 ] </pre><p> Please look into this. Did you by any chance compile and run this test? If so, on what system? </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <author>kfriddile@…</author> <pubDate>Thu, 16 Apr 2009 17:55:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2912#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2912#comment:3</guid> <description> <p> I've only tested it with MSVC 8 and it works there. I don't have MSVC 7.1 to test with. It seems to be a problem with std::bitset::to_string(). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Sun, 26 Apr 2009 16:59:36 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2912#comment:4 https://svn.boost.org/trac10/ticket/2912#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> I've made changes and it seems to test well here and I will shortly upload to the trunk. I only made the minimal changes required to make it work "everywhere". In looking at it though, I have a couple of observations. </p> <p> Someone is going to complain that it's not very efficient when storing to binary files. Perhaps you want to consider specializations for size &lt; 8, size &lt; 16, size &lt; 32 so that it's stored in an unsigned integer. Downside is that this would require going into MPL which requires more effort. </p> <p> Robert Ramey </p> Ticket