quote:Original post by Monderquote:Original post by psamty10quote:Original post by Magmai Kai Holmlor
Actually, you shouldn''t use LPDIRECT3DDEVICE9 et. al.
You should use smart-pointers:
CComPtr<IDirect3DDevice> device;
Care to provide a reason why?.... I''ve never looked at smart pointers as particularly useful except for resources shared across multiple objects. I certainly dont think you should use them everywhere... *cough* massive performance hit *cough*
<SPAN CLASS=editedby>[edited by - psamty10 on May 22, 2004 12:38:10 AM]</SPAN>
If you use smart pointers memork leaks can become a thing of the past, which is good. As for the performance hit it''s a single function call when the smart pointer is constructructed and a single function call when it is deconstructed, as well a function call in things such as copy constructors and assignment operators. I really don''t see it causing a major performance hit. If it does you''re probably using them wrongly.
I''m guessing that psamty10 has heard/seen that smart pointers contain a method to access the contained object & has not realised that it will be optimised away by the compiler so that it effectivelly doesn''t exist, either that or he''s confusing it for GC (fwiw, the Hans Bohem collector is (apparently) 27% slower on average for allocation, no hit at any other time --- the GC in Java gives GC a bad name --- GC, however, is an excellent way of banishing memory leaks for ever!)