[omniORB] Sequence of valuetypes in C++

Duncan Grisby duncan at grisby.org
Wed Sep 6 19:02:30 BST 2006


On Tuesday 5 September, "Tamas Kerecsen" wrote:

> I've noticed an odd behavior when I started experimenting with valuetypes. I
> have a sequence that contains valuetype objects. When I set values in the
> sequence (doing something like seq[0] = obj1), the reference count of the
> objects are not incremented. However when the sequence goes out of scope, it
> decrements the reference count of all the objects contained within. This is
> asymmetrical.

That is exactly the same as the behaviour with object references.

> All the rest of the C++ mapping seems to function intuitively (meaning that
> you can use _var smart pointers for everything and never have to use
> pointers, or call add_ref or remove_ref directly) except for this sequence
> case, and the case of _downcast.

You can do the same with valuetypes. As long as you are holding your
values in _vars, their reference counts are incremented when they are
put into sequences.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list