|
Boost : |
From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-04-11 11:47:01
On Fri, 2008-04-11 at 09:40 -0400, Frank Mori Hess wrote:
> On Thursday 10 April 2008 19:13 pm, Daniel Frey wrote:
> > I like that you call _internal_accept_owner on T* directly, still I
> > think that I template class for tagging has some advantages. See the
> > attached code I played with. In it, A has the role of the tag class. As
> > the code shows, it is possible to have multiple classes like these, you
> > just need some manual forwarding in the more complicated cases.
>
> I don't understand what the benefit will be when applied to
> shared_ptr_observer? All I get from the example is that if you have a class
> X derived from A<T>, you can tell whether X and T are the same type or not.
> Manual forwarding works just as well without a template parameter. Maybe if
> you explained (as if writing user documentation for the feature) what the
> template argument of shared_ptr_observer is supposed to be set to, and what
> effect it would have? The behavior associated with a non-template
> shared_ptr_observer tag can be spelled out in 1 or 2 sentences.
I enhanced the example and added some comments. The reason for having a
template tag class is that you can fix otherwise problematic cases when
multiple tags are present. I don't think we can do the redirection
automatically (except when someone adds compile-time reflection that
allows us to iterator over the base classes), but at least there is a
way to support this use case by a little bit of extra work.
Regards, Daniel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk