2010-11-29 14 views
0

COMインターフェイスによって返されたハンドルをカプセル化するバインド:::ブーストは、私はこのようなCOMオブジェクトを使用するVisual Studio 2008のC++プロジェクトを持っている

ISomeComInterface* foo; 
HANDLE file = foo->CreateFile(); 
// file operations... 
foo->CloseHandle(file); 

私はの寿命管理をカプセル化するboost::shared_ptr<>を使用したいです返されたHANDLEオブジェクト例えば:

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

+1

あなたは 'BOOST_MEM_FN_ENABLE_STDCALL'を定義しましたか? (http://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html#Q_comをご覧ください) –

+0

@Eric Malenfant - それが修正されました。ありがとうございました。 – PaulH

答えて

0

エリックが質問に答え

#define BOOST_MEM_FN_ENABLE_STDCALL

htttp://www.boost.org/doc/libs/1_45_0/libs/bind/bind.html#Q_com

関連する問題