[Serialization] Serializing boost::tuples
Hi there, I know that serializing of std::pair is part of the current serialization lib. I'm just wondering if there is something for the boost's tuples? Is it maybe in a different header file? I think that would be a cool feature and not so difficult to implement. But maybe I'm naive? Thanks, Christian
I don't know of anyone having done it. I would expect it to be similar to pair. If you do this, feel free to upload it to the vault. Robert Ramey Christian Henning wrote:
Hi there, I know that serializing of std::pair is part of the current serialization lib. I'm just wondering if there is something for the boost's tuples? Is it maybe in a different header file?
I think that would be a cool feature and not so difficult to implement. But maybe I'm naive?
Thanks, Christian
Hi Robert, I would be interested in doing that. Here is what I would like to achieve: typedef tuple< string, string, string > Key; typedef map< Key, int > MyMap; int _tmain(int argc, _TCHAR* argv[]) { MyMap aMap; { const MyMap& caMap = aMap; ofstream ofs( "Settings.txt" ); boost::archive::text_oarchive oa( ofs ); oa & caMap; } return 0; } This code fails because no serialize function is defined for the Key type. Can you point me to the code section that does the serialization of std::pair. Thanks, Christian
boost/serialization/utility.hpp since pair is in <utility> Christian Henning wrote:
Hi Robert, I would be interested in doing that. Here is what I would like to achieve:
typedef tuple< string, string, string > Key; typedef map< Key, int > MyMap;
int _tmain(int argc, _TCHAR* argv[]) { MyMap aMap;
{ const MyMap& caMap = aMap; ofstream ofs( "Settings.txt" ); boost::archive::text_oarchive oa( ofs );
oa & caMap; }
return 0; }
This code fails because no serialize function is defined for the Key type.
Can you point me to the code section that does the serialization of std::pair.
Thanks, Christian
Thanks Robert, here is my proof of concept for a triple ( tuple with 3
entries ). Any comments? I'm on MSVC 7.1.
namespace boost {
namespace serialization {
// triple
template
Hi Robert, I uploaded the code to the vault/serialization. The code allows to serialize tuples up to 10 values. I also included test cases. Regards, Christian
participants (2)
-
Christian Henning
-
Robert Ramey