|
Boost : |
Subject: Re: [boost] [serialization] non-tracking wrapper?
From: David Abrahams (dave_at_[hidden])
Date: 2008-11-12 12:25:46
on Wed Nov 12 2008, joaquin-AT-tid.es wrote:
> I think something to this effect can be implemented resorting to
> <drumroll>helper support</drumroll>. Non-tested pseudocode follows.
> The idea is not to supress tracking (which can't be done) but rather to move
> stack-based
> objects to a safe location so that Boost.Serialization does not get confused by
> objects
> with potentially the same stack address.
>
> template<typename T>
> struct non_tracking
> {
> non_tracking():p(0){}
> non_tracking(const T& t):p(&t){}
>
> const T& get()const{return *p;}
>
> const T* p;
>
> struct helper
> {
> typedef std::list<T> table_type;
> table_type table;
> };
>
> template<class Archive>
> void save(Archive & ar,const unsigned int)const
> {
> helper::table_type& table=ar.get_helper<helper>().table;
> table.push_back(*p);
> ar<<table.back();
> }
>
> template<class Archive>
> void load(Archive & ar,const unsigned int)
> {
> helper::table_type& table=ar.get_helper<helper>().table;
> T t;
> ar>>t;
^^^^^
Not that I really need this feature, but what is going to prevent the
library from doing the usual thing it does when deserializing T here?
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk