[omniORB] Deletect failed allocation to a _var
Clarke Brunt
clarke.brunt at trafficmaster.co.uk
Thu Jun 5 14:22:02 BST 2008
>At one point of the code, they are performing as assert check to make
>sure that a new operation succeeded. The code :
>
>CosNaming::Name_var compound_name = new CosNaming::Name(count);
>assert(compound_var != 0);
>...
>So the question. How would I check to confirm that the new worked
>successfully. I guess maybe something with operator ->, but I am not
>experienced enough in that part of C++ to see how.
As someone has already said, if 'new' itself throws an exception, then maybe
this isn't relevant. But I've wanted to check in programs whether or not a
var has been 'filled in' or not.
I half-recall the spec. saying that one mustn't 'use' vars before allocating
something to them, but anyway, the way with operator-> is simply:
assert(compound_var.operator->() != 0)
I don't think CORBA::is_nil() is any good - isn't that only for object
references?
--
Clarke Brunt
More information about the omniORB-list
mailing list