Questions about getCppuType

julien2412 serval2412 at yahoo.fr
Fri Apr 25 04:04:39 PDT 2014


sberg wrote
> ...
> getCppuType is not without flaws though, and cppu::UnoType should be 
> used instead.
> ...
> What cast are you talking about?  The one in the typical usage like 
> getCppuType((T*)0)?  Sure, nothing keeps you from writing that as 
> getCppuType(static_cast<T*>(0)), or better yet, cppu::UnoType
> <T>
> ::get(), 
> instead.

Thank you Stephan for your feedback and the detailed explanations.
Yes I was talking about this typical usage.
Great if cppu::UnoType<T>::get() is better than getCppuType usage!
It will serve 2 goals then:
1) a better usage
2) a fix to cppcheck report "Expression is always false because 'else if'
condition matches previous condition at line..." for this type of case
(of course, I consider 1) more important but it will kill 2 birds with one
stone)

Eg in sfx2/source/toolbox/tbxitem.cxx, I could change:
else if ( pType == ::getCppuType((const sal_uInt32*)0) )
to 
else if ( pType == cppu::UnoType<const sal_uInt32>::get() )

Just to be sure, it would then mean that getCppuType could be removed after
having replaced all the occurences of getCppuType by cppu::UnoType... or are
there some special/specific cases?

Julien



--
View this message in context: http://nabble.documentfoundation.org/Questions-about-getCppuType-tp4106361p4106403.html
Sent from the Dev mailing list archive at Nabble.com.


More information about the LibreOffice mailing list