Hi Rainman,

> After a period of time of developing with URE, I find the C++ UNO
> class Reference is not very comfortable for use sometime.
> The problem is, when I have a reference of base interface XA and a
> reference of derived interface XB, I can't make xA = xB directly.
> Instead I have to query XA from xB like this xA = Reference<XA>::query(xB).

¨xA = xB.get()¨ would do, too, and be less expensive.

> I wonder that whether we can use template constructors to simply this
> situation.These constructors may something like this:
> 
> template <typename interface_type>
> class Reference
> {
>     template <_interface_type>
>     Reference(const Reference<_interface_type>& rRef)
>     {
>         interface_type* p = NULL;
>         _interface_type* _p = NULL;
>         p = _p; // compiling time cast check.
>         _pInterface = iquery( rRef.get() );

The last two lines could be to just assigning (and aquiring) rRef.get()
to _pInterface.

>     }
> ...
> Now we can simplify the cast code above to
> xA = xB;

I am not sure we should do this, implicit constructors usually add
ambiguity ...

Ciao
Frank

-- 
- Frank Schönheit, Software Engineer         [email protected] -
- Sun Microsystems                      http://www.sun.com/staroffice -
- OpenOffice.org Base                       http://dba.openoffice.org -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to