6

I just got started with DirectX 11.1 for Windows 8 apps and I got the following ComPtr for example:

ComPtr<ID3D11Buffer> constantBuffer;

What I wonder is, what is the difference between using &constantBuffer and constantBuffer.GetAddressOf()?

Sometimes they both works fine, but sometimes using &constantBuffer will cause my program to crash with an access violation.

Johan Falk
  • 4,341
  • 2
  • 30
  • 42

1 Answers1

7

Did you read documentation?

GetAddressOf - Retrieves the address of the ptr_ data member, which contains a pointer to the interface represented by this ComPtr.

Operator& - Releases the interface associated with this ComPtr object and then retrieves the address of the ComPtr object.

nothrow
  • 15,882
  • 9
  • 57
  • 104
  • Ye, I read the documentation, but didn't see the remark that it releases the interface. Now I understand why it crashed as it did, thanks! – Johan Falk Dec 22 '12 at 22:19