Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-06-22 06:13:56


Gottlob Frege wrote:

[...]

> typedef int RecordID;
>
> assign(RecordID id, SomeValue const & value)
> {
> // do the assignment
> }
>
> But of course, RecordID is just a typedef, not a 'strong typedef',
> so it could be just one example of many assign(int, SomeValue),
> completely unrelated to each other.
>
> So how should that be handled? Specific naming (using 'myclass_')
> lowers the chances of a problem, but doesn't remove it. Which means
> that, in theory at least, intrusive_ptr has the same problem:
>
> intrusive_ptr_add_ref(some_typedef_that_is_really_an_int)
> { ... }
>
> intrusive_ptr_add_ref(some_OTHER_typedef_that_is_also_an_int)
> { ... }

intrusive_ptr_add_ref is passed a pointer to a class with an embedded
reference count. It doesn't matter how many typedefs resolve to X*, X still
has its reference count that needs to be incremented.

You only run into the problem when "assign" is underspecified and overloaded
to mean different things in different contexts.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net