refclass and Hat ^

Marian Luparu, Jim Springfield and other VC++ folks from Channel9.

Windows 8 is a change for developers to write applications. Consuming WinRT API is the way to go. C++ is part of that. How to write great Metro Apps with C++.

WRL is a library. CX are C++ extensions. Hat is a pointer. ^ means *.

^ is a CComPtr. It a counter-based COM pointer. Refnew is used to activate a WinRT component.

In Windows team, the code is exception free. So how Windows team consumes WRL gave good feedback. Example:

CComPtr<IFoo> f; auto b=f.As<IBar>(); if( b == nullptr ) {…}

It needs to return the HRESULT explaining why if failed because QI (COM QueryInterface) returns an HRESULT with explains.

HRESULT hr = f.As<IBar>();

Other example:

IFoo * pf; IBar *pb; pb = pf; It should be mapped to CComPtr<IFoo> pf; CComPtr<IBar> pb = pf;

auto a = ref new uri(); // RoActivateInstance(“W::F::Uri”, &p);

It is life-time managed like a shared_ptr<T>.

It is easier to write COM now.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: