(I suppose you're talking about demarshalling.) How does the
user call your function if the class doesn't have a default
constructor?
If someone wants to build/receive a vector<Account>,
we require a default constructor be available. If
they want to demarshall one Account, they have to
pass an Account object to the function -- the object
in that case could have been constructed by a ctor
other than the default constructor. It seems like
I read that C++0X containers require value types
to have default constructors also.
It's actually a non-trivial problem, since most of the types I
want to make persistent don't support copy either. The usual
solution I've seen in such cases is to provide a constructor
which takes your demarshalling data source (istream or
whatever), and have a function which does something like:
return new ClassType( source ) ;
Currently we support both return codes and exceptions
for error handling. If we were to drop support for
return codes, I'd be more inclined to support
streaming constructors. In that case, we could use
that constructor with a vector<Account> and not
need to use a default constructor. Do you have
cases where you can't have a default constructor?
There is some tension though with the idea of
message support here. Say there are classes
A and B and a message that consists of an A
object followed by a B object. Currently I
would have a Send function like so
Send(Buffer buf, const A& abt1, const B& abt2);
and a Receive function
Receive(Buffer buf, A& abt1, B& abt2); .
The implementation of Send would send
a message id and the appropriate Receive
function would be called based on what
message id is received. It seems that
avoiding default constructors in this
case would make it more difficult to
preserve the message concept/automation;
users would have to make sure they
correctly maintained the order of the
marshalled objects themselves.
Brian Wood
http://webEbenezer.net