Boost logo

Boost :

Subject: Re: [boost] [Serialization] serialize from and to an alreadyinstantiated object.
From: Nicolas Guillot (nicolas.guillot_at_[hidden])
Date: 2011-06-10 08:43:36

Robert Ramey <ramey <at>> writes:

> If you REALLY want something like this, consider something
> [...]
> I'm not sure what else to say about this.
> Robert Ramey

Thanks for your reply.
First: I don't REALLY want my syntax: indeed, provide a "free" function as you
suggest is a simple (good) way to add the "savable" feature.

One question remains: how to deserialize onto an already instantiated object?
Or: how to implement the Load function better than:

template<class T>
void FileLoad(const std::string & path, T & t){
    std::ifstream ifs(path.c_str());
    T* p;
    ia >> p;
    t = *p;
    delete p;

which is not exception safe, and not efficient.


Boost list run by bdawes at, gregod at, cpdaniel at, john at