Opened 14 years ago
Closed 13 years ago
#2912 closed Patches (fixed)
implementation of std::bitset serialization
Reported by: | Owned by: | Robert Ramey | |
---|---|---|---|
Milestone: | To Be Determined | Component: | serialization |
Version: | Boost Development Trunk | Severity: | Not Applicable |
Keywords: | Cc: |
Description
I have attached an implementation of std::bitset serialization and the associated unit test for consideration for future addition to the serialization library.
Attachments (2)
Change History (6)
by , 14 years ago
Attachment: | bitset.hpp added |
---|
comment:1 by , 14 years ago
Status: | new → assigned |
---|
comment:2 by , 14 years ago
When I try and compile the test - Get compile errors with MSVC 7.1
Compiling... test_bitset.cpp c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(39) : error C2783: 'std::basic_string<_Elem,_Traits,_Ax> std::bitset<_Bits>::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<_Bits>::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<Archive,8>(Archive &,const std::bitset<_Bits> &,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<Archive,T>::invoke(Archive &,const T &,const unsigned int)' with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_free.hpp(74) : see reference to class template instantiation 'boost::serialization::free_saver<Archive,T>' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(59) : see reference to function template instantiation 'void boost::serialization::split_free<Archive,std::bitset<_Bits>>(Archive &,T &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, _Bits=8, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\serialization.hpp(133) : see reference to function template instantiation 'void std::serialize<Archive,8>(Archive &,std::bitset<_Bits> &,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<Archive,T>(Archive &,T &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\extended_type_info_typeid.hpp(74) : while compiling class-template member function 'void boost::archive::detail::oserializer<Archive,T>::save_object_data(boost::archive::detail::basic_oarchive &,const void *) const' with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(236) : see reference to class template instantiation 'boost::archive::detail::oserializer<Archive,T>' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] 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<Archive,T>::save_standard::invoke(Archive &,const T &)' with [ Archive=boost::archive::text_oarchive, T=std::bitset<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<Archive,T>::save_standard' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] 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<Archive,T>::invoke(Archive &,const T &)' with [ Archive=boost::archiv e::text_oarchive, T=std::bitset<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<Archive,T>' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,const T &)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\basic_text_oarchive.hpp(75) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<const T>(const T &,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\interface_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<const T>(const T &,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\nvp.hpp(78) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<const T>(const T &)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\access.hpp(93) : see reference to function template instantiation 'void boost::serialization::nvp<T>::save<Archive> (Archivex &,const unsigned int) const' being compiled with [ T=std::bitset<8>, 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<Archive,const T>(Archive &,const T &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_member.hpp(42) : while compiling class-template member function 'void boost::serialization::detail::member_saver<Archive,T>::invoke(Archive &,const T &,const unsigned int)' with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\split_member.hpp(69) : see reference to class template instantiation 'boost::serialization::detail::member_saver<Archive,T>' being compiled with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\nvp.hpp(88) : see reference to function template instantiation 'void boost::serialization::split_member<Archive,boost::serialization::nvp<T>>(Archive &,boost::serialization::nvp<T> &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\access.hpp(109) : see reference to function template instantiation 'void boost::serialization::nvp<T>::serialize<Archive>(Archive &,const unsigned int)' being compiled with [ T=std::bitset<8>, 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<Archive,T>(Archive &,T &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\serialization.hpp(133) : see reference to function template instantiation 'void boost::serialization::serialize<Archive,T>(Archive &,T &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\oserializer.hpp(224) : see reference to function template instantiation 'void boost::serialization::serialize_adl<Archive,T>(Archive &,T &,const unsigned int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp<std::bitset<8>> ] 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<Archive,T>::save_only::invoke(Archive &,const boost::serialization::nvp<std::bitset<_Bits>> &)' with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>>, _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<Archive,T>::save_only' being compiled with [ Archi ve=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>> ] 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<Archive,T>::invoke(Archive &,const boost::serialization::nvp<std::bitset<_Bits>> &)' with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>>, _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<Archive,T>' being compiled with [ Archive=boost::archive::text_oarchive, T=boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\common_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::save<Archive,T>(Archive &,T &)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\basic_text_oarchive.hpp(75) : see reference to function template instantiation 'void boost::archive::detail::common_oarchive<Archive>::save_override<T>(T &,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp<std::bitset<8>> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\archive\detail\interface_oarchive.hpp(64) : see reference to function template instantiation 'void boost::archive::basic_text_oarchive<Archive>::save_override<T>(T &,int)' being compiled with [ Archive=boost::archive::text_oarchive, T=const boost::serialization::nvp<std::bitset<8>> ] \BoostRelease\libs\serialization\test\test_bitset.cpp(47) : see reference to function template instantiation 'Archive &boost::archive::detail::interface_oarchive<Archive>::operator <<<const boost::serialization::nvp<T>>(const boost::serialization::nvp<T> &)' being compiled with [ Archive=boost::archive::text_oarchive, T=std::bitset<8> ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(39) : error C2783: 'std::basic_string<_Elem,_Traits,_Ax> std::bitset<_Bits>::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<_Bits>::to_string' with [ _Bits=8 ] c:\BoostRelease\libs\serialization\vc7ide\..\..\..\boost\serialization\bitset.hpp(39) : error C2783: 'std::basic_string<_Elem,_Traits,_Ax> std::bitset<_Bits>::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<_Bits>::to_string' with [ _Bits=8 ]
Please look into this. Did you by any chance compile and run this test? If so, on what system?
Robert Ramey
comment:3 by , 14 years ago
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().
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
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.
Someone is going to complain that it's not very efficient when storing to binary files. Perhaps you want to consider specializations for size < 8, size < 16, size < 32 so that it's stored in an unsigned integer. Downside is that this would require going into MPL which requires more effort.
Robert Ramey
serialization support for std::bitset