|
Boost : |
From: Robert Ramey (ramey_at_[hidden])
Date: 2003-10-13 13:58:45
David Abrahams wrote:
>What if there's just no default constructor, private or otherwise?
Currently you would have to overload:
template<class Archive, class T>
void load(Archive &ar, T * &t, unsigned int version)
...
for the specifice collection with something like
template<class Archive>
void load(Archive &ar, vector<A> &va, unsigned int version){
unsigned int size;
va.clear();
ar >> size;
while(size-- > 0){
int i;
ar >> i;
A a(i);
ar >> a;
va.pushback(a);
}
}
That is the current default implementation of collection serializaton presumes
the existence of a default constructor for the element. If this isn't true
then the default implementation won't work and you'll have to make your
own override.
Robert Ramey
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk