conversion operators for UNO

Stephan Bergmann sbergman at redhat.com
Tue Apr 30 09:42:16 PDT 2013


On 04/30/2013 05:55 PM, Thorsten Behrens wrote:
>> On 04/25/2013 10:35 AM, Noel Grandin wrote:
>>> I want to change things so that I can write:
>>>    void bar() {
>>>        Reference<B> b = ....
>>>        methodThatTakesA( b );
>>>    }
>>
> Yeah. One of my older pet peeves...
>
> Stephan Bergmann wrote:
>> This has been discussed before more than once, but I tend to forget
>> whether it has never gone past discussion stage because the
>> implementation would be slightly tricky (using SFNIAE to restrict
>> implicit conversions from Reference<B> to Reference<A> to cases
>> where B is derived from A) or because there was some fundamental
>> flaw with it.
>>
> Works by and large with the proof of concept from
>
>   https://gerrit.libreoffice.org/#/c/3698/
>
> , the only problem I recall, is a slight performance degradation,
> since IIRC then operator Reference<XInterface>& needs to go due to
> ambiguities (which avoids temporaries). Possibly offset nicely by
> needing much less queryInterfaces...

So I came up in parallel with <https://gerrit.libreoffice.org/#/c/3699/> 
that does not require to include Boost headers in URE headers (though at 
the expense of borrowing some concepts from boost::is_base_and_derived, 
ultimately to be cleaned up with C++11 std::is_base_of), coexists 
happily with the Reference<XInterface> conversion operator, doesn't 
require changes all over the place (compared to Noel's 
<https://gerrit.libreoffice.org/#/c/3613/> I started it off from), 
doesn't use queryInterface internally (but thus doesn't support 
ambiguous up-casts in MI scenarios).

I'm giving it a try currently on the gerrit bulidbots (and will be back 
next Monday to discuss further).

Stephan



More information about the LibreOffice mailing list