[cairo] [cairomm] RefPtr<T>::operator*() ?

Murray Cumming murrayc at murrayc.com
Wed Aug 20 07:47:13 PDT 2008


On Wed, 2008-08-20 at 11:29 -0300, Ian Britten wrote:
> Jonathon Jongsma wrote:
> 
> >> Just a suggestion, but it might be nice if the cairomm RefPtr
> >> class had an operator*() (Or, a get(), or something).
> >>
> >> Otherwise, if func() is written to accept a "const T &", you
> >> have to write code like:
> >>         Cairo::RefPtr<T> someObj;  (Populated from somewhere)
> >>         func( *someObj.operator->() );
> >> instead of the simpler/cleaner
> >>         func( *someObj );
> 
> > If there is API in cairomm that accepts a 'const T&' where T is supposed 
> > to be used via RefPtr, it is likely an API bug.  Unfortunately I 
> > discovered one of these just in the last couple days (the ScaledFont 
> > constructor) and plan to fix it in a future release.  If you find 
> > further places where this is the case, please file a bug.
> 
> Oops!  Sorry if I wasn't clear...
> In my example, func() was one of my own functions that I had
> written (It was actually a template function, but that's irrelevant
> to this).
> I didn't mean to imply it was a cairomm function.

So you should rewrite that function to take a const
Glib::RefPtr<SomeCairoThing>& instead.

In general we don't have an operator* because people would use it when
they shouldn't, without knowing that they shouldn't.

-- 
murrayc at murrayc.com
www.murrayc.com
www.openismus.com



More information about the cairo mailing list