Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Serializing derived
From: Brown, Matt (Matt.Brown_at_[hidden])
Date: 2013-01-18 17:39:21


Hi Daniel,

You may have already considered this option, but what if you were to require a template argument for which the user could pass a serialization behavior class ... much like an allocator for STL containers.

I.E.
YOUR CODE:
template <typename T, typename serialize_T>
struct container
{
  void serialize(unsigned version) {serialize_T::do(data, version);}
  virtual ~container() = default;
  T data;
};

USER'S CODE:
struct my_serialize
{
  static void do(SOME_TYPE data, unsigned version) {<user does what's needed here>}
};
typedef container<SOME_TYPE, my_serialize> my_container;

Maybe of some help to you?

-- Matt

________________________________

This e-mail contains privileged and confidential information intended for the use of the addressees named above. If you are not the intended recipient of this e-mail, you are hereby notified that you must not disseminate, copy or take any action in respect of any information contained in it. If you have received this e-mail in error, please notify the sender immediately by e-mail and immediately destroy this e-mail and its attachments.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net