Questions about getCppuType

Stephan Bergmann sbergman at
Fri Apr 25 03:18:22 PDT 2014

On 04/25/2014 07:55 AM, julien2412 wrote:
> Seeing the number of times getCppuType is used, I've got several questions
> about this:
> - what's the use of it? It resembles at the first look to "typeid" but I
> suppose it's not this.

Yes, it's to the C++ UNO language binding what typeid is to C++, mapping 
from a C++ type representing a UNO type to a css::uno::Type instance 
describing that UNO type.

getCppuType is not without flaws though, and cppu::UnoType should be 
used instead.

> - could there be an alternative? (eg a more "native"/straightforward C++
> way)?

Not really.

> - if it still must be used, could the C style cast be changed in static cast
> (to be sure the cast is in build time and so the check is also  in build
> time)?

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(), 


More information about the LibreOffice mailing list