Hi *, when one needs to convert between two interface types from the same hierarchy (say, from awt::XWindow2 to awt::XWindow), copy-constructing or assigning the corresponding uno::Reference types will fail:
Example 1: void foo( uno::Reference< awt::XWindow > const& win ); uno::Reference< awt::XWindow2 > xWin; foo( xWin ); -> ERROR uno::Reference< awt::XWindow > xWinBase; xWinBase = xWin; -> ERROR Which is kind of surprising for the casual observer (and a common case nowadays, with lots of 2er and 3er versions of interfaces), because plain pointers of related types behave that way. Of course, you can circumvent the problem like this: Example 2: foo( xWin.get() ); (this works, because now the implicit conversion to the base pointer kicks in, and the uno::Reference<awt::XWindow> constructor is automatically called). My proposal now is, to add both a templatized copy constructor and assignment operator to uno::Reference, such that example 1 works: --%<---------------------------------------------------------------- + /* Constructor: copy-construct from derived interface + + @param rRef + Interface reference that must be convertible to interface_type + (typically, this implies that interface_type is a basetype of + the passed type) + */ + template< class Ifc > inline Reference( const Reference<Ifc>& rRef ); + /* Assignment operator: assign from derived interface + + @param rRef + Interface reference that must be convertible to interface_type + (typically, this implies that interface_type is a basetype of + the passed type) + */ + template< class Ifc > inline Reference< interface_type >& + operator =( const Reference<Ifc>& rRef ); --%<---------------------------------------------------------------- What do you think? -- Thorsten If you're not failing some of the time, you're not trying hard enough. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
