使用 COM Object/CComPtr 和 STL 时的建议
我正在使用 directshow 做一些与 COM 相关的事情,例如:
typedef CComPtr<IBaseFilter> AutoIBaseFilterPtr;
map<CString, AutoIBaseFilterPtr> _filterMap;
存储与 directShow 相关的 com 对象及其友好名称的列表。
找到 这篇文章(参见:问题2)介绍了 VC10 编译器中的更改如何影响以前正常的代码,我想知道在混合 STL 和 CComPtr 时是否还有更多需要注意的事情,或者只是一般来说,混合 STL 和 COM。
任何提示将不胜感激,谢谢
I am doing some COM related things with directshow such as:
typedef CComPtr<IBaseFilter> AutoIBaseFilterPtr;
map<CString, AutoIBaseFilterPtr> _filterMap;
To store a list of directShow related com objects and their friendly name.
After finding this article (See:Problem 2) on how changes in VC10 compiler might effect previously OK code, I am wondering if there are any more things to watch out for when mixing the STL and CComPtr or prehaps just mixing the STL and COM in general.
Any tips would be greatly appreciated, thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能想到的唯一没有提到的小事情是,
CComBSTR
以及CComPtr
都需要CAdapt
,因为它会重载operator&
也是如此。事实上,重载
operator&
使得CAdapt
成为必要,因为许多 STL 容器要求获取某个 X 的地址返回一个指向该 X 的指针。The only slight thing I can think of that hasn't been mentioned is that
CAdapt
is required forCComBSTR
as well asCComPtr
, because it overloadsoperator&
too.In fact, it is overloading
operator&
that makesCAdapt
necessary, as many STL containers require that taking the address of something X returns a pointer to said X.