我有一个使用如下COM对象的Visual Studio 2008 c ++项目:
ISomeComInterface* foo;
HANDLE file = foo->CreateFile();
// file operations...
foo->CloseHandle( file );
我想使用boost::shared_ptr<>
来封装返回的HANDLE
对象的生命周期管理。 e.g:
ISomeComInterface* foo;
boost::shared_ptr< void > file( foo->CreateFile(),
boost::bind( &ISomeComInterface::CloseHandle, foo, _1 ) );
// file operations...
不幸的是,这不会编译:
1>Compiling...
1>Audit Tool.cpp
1>boost\bind\bind.hpp(69) : error C2825: 'F': must be a class or namespace when followed by '::'
1> boost\bind\bind_template.hpp(15) : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' being compiled
1> with
1> [
1> R=boost::_bi::unspecified,
1> F=int (__stdcall ISomeComInterface::* )(HANDLE)
1> ]
1> Myapp.hpp(78) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
1> with
1> [
1> R=boost::_bi::unspecified,
1> F=BOOL (__stdcall ISomeComInterface::* )(HANDLE),
1> L=boost::_bi::list2<boost::_bi::value<ISomeComInterface *>,boost::arg<1>>
1> ]
1>boost\bind\bind.hpp(69) : error C2039: 'result_type' : is not a member of '`global namespace''
1>boost\bind\bind.hpp(69) : error C2146: syntax error : missing ';' before identifier 'type'
1>boost\bind\bind.hpp(69) : error C2208: 'boost::_bi::type' : no members defined using this type
1>boost\bind\bind.hpp(69) : fatal error C1903: unable to recover from previous error(s); stopping compilation
我可以做些什么来获得我正在寻找的功能?
谢谢, PaulH
答案 0 :(得分:0)
Eric回答了这个问题
#define BOOST_MEM_FN_ENABLE_STDCALL
HTTTP://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html#Q_com