After the second coming of COM, otherwise known as the Windows Runtime, the need for an efficient and reliable smart pointer for COM interfaces is more important than ever. But what makes for a good COM smart pointer? The ATL CComPtr class template has been the de facto COM smart pointer for what feels like decades. The Windows SDK for Windows 8 introduced the ComPtr class template as part of the Windows Runtime C++ Template Library (WRL), which some hailed as a modern replacement for the ATL CComPtr. At first, I also thought this was a good step forward, but after a lot of experience using the WRL ComPtr, I've come to the conclusion it should be avoided. Why? Keep reading.
展开▼
机译:在第二次出现COM(也称为Windows运行时)之后,对COM接口的高效可靠的智能指针的需求比以往任何时候都更加重要。但是,什么才是好的COM智能指针呢? ATL CComPtr类模板实际上已经成为数十年来感觉像的COM智能指针。 Windows 8的Windows SDK引入了ComPtr类模板,将其作为Windows运行时C ++模板库(WRL)的一部分,其中一些被誉为ATL CComPtr的现代替代品。起初,我还认为这是向前迈出的一大步,但是经过使用WRL ComPtr的大量经验,我得出的结论是应避免使用它。为什么?继续阅读。
展开▼