Stl question

Started by
12 comments, last by Pactuul 21 years, 10 months ago
[tangential but useful:]
While on the topic of simplifying object management (using maps, etc), you might also want to consider using CComPtr to manage all your COM interfaces (DirectX). You''ll never have to call Release or write another SAFE_DELETE macro again. It''s in the &ltaltbase.h> header file, and is a real time saver. You can stick references to them in your map if space is an issue.
Advertisement
Oluseyi- while looking for solutions and such in the forums, i''ve seen you talk about the CComPtr(). i''ve read up on it, but i''m not sure how to apply it correctly in my case. In other words, how would you implement into the code correctly?
-Pac "The thing I like about friends in my classes is that they can't access my private members directly." "When listening to some one tell about their problem (whether it's code or not), don't listen to what went right or wrong, but what they assumed....."
quote:Original post by Pactuul
Oluseyi- while looking for solutions and such in the forums, i''ve seen you talk about the CComPtr(). i''ve read up on it, but i''m not sure how to apply it correctly in my case. In other words, how would you implement into the code correctly?

In general, you would use CComPtr like so:

  CComPtr <IInterface> interface;CoCreateInstance(..., &interface);// Don''t call Release; CComPtr will call it for you when interface goes out of scope  

Keep in mind that you can''t generally use CComPtr in containers because it overloads operator &. I had a big problem with std::vector''s of CComPtr''s of IDirect3DTexture8''s due to this; check my profile for the thread link. There are some code snippets in that thread as well.
---visit #directxdev on afternet <- not just for directx, despite the name

  HRESULT hr;CComPtr <IInterface> pInterface;if(FAILED(hr = pInterface.CoCreate(CLSID_CoInterface))) return hr;pInterface->InterfaceMethod(...);  
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement