Modify

Ticket #2912 (closed Patches: fixed)

Opened 5 years ago

Last modified 5 years ago

implementation of std::bitset serialization

Reported by: kfriddile@… Owned by: 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

bitset.hpp Download (1.7 KB) - added by kfriddile@… 5 years ago.
serialization support for std::bitset
test_bitset.cpp Download (1.5 KB) - added by kfriddile@… 5 years ago.
unit test for std::bitset serialization

Change History

Changed 5 years ago by kfriddile@…

serialization support for std::bitset

Changed 5 years ago by kfriddile@…

unit test for std::bitset serialization

comment:1 Changed 5 years ago by ramey

  • Status changed from new to assigned

comment:2 Changed 5 years ago by ramey

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 Changed 5 years ago by kfriddile@…

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 Changed 5 years ago by ramey

  • Status changed from assigned to closed
  • Resolution set to fixed

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

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.