|
Boost : |
From: Loïc Joly (loic.actarus.joly_at_[hidden])
Date: 2005-08-23 15:49:14
Hello everybody,
I've read the rationale for only allowing const trackable objects, but
here is my problem :
I want to serialize the following class :
class C : boost::noncopyable
{
public:
void setData(string s) {data = s;}
//...
};
int main()
{
C c;
c.setData("Hello world");
vector <C*> v;
v.push_back(&c);
//...
ar << c << c;
}
To have a c with meaningfull data, it cannot be const.
I cannot create a local object that is a copy of the object (it is
noncopyable)
I do not think making the object untracked would be a good idea in this
case (I might be wrong ?)
So far, the best way I found to be able to serialize this object is :
C const & cForSerialize = c;
ar << cForSerialize << cForSerialize;
But I do not think this is really elegant code. Is there a better
alternative ?
-- Loïc
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk