[mem_fn] Ambiguous call to mem_fn with stdcall function

I'm trying to use g++ (and MinGW) to compile a win32 Direct3X program
that I've written under Visual C++. All is well (so far) except for one
thing.
I'm using the technique suggested in the Boost shared_ptr documentation
to store pointers to COM objects, which works fine under Visual C++ but
under g++ (either 3.4.x or 4.3.x) I get errors about the call to mem_fn
being ambiguous due to stdcall / non-stdcall overloading.
I can't find any references to this problem on the net so I assume I'm
doing something utterly boneheaded. Any hints would be very welcome.
For example:
#define BOOST_MEM_FN_ENABLE_STDCALL
#include

Conrad Scott:
I'm trying to use g++ (and MinGW) to compile a win32 Direct3X program that I've written under Visual C++. All is well (so far) except for one thing.
I'm using the technique suggested in the Boost shared_ptr documentation to store pointers to COM objects, which works fine under Visual C++ but under g++ (either 3.4.x or 4.3.x) I get errors about the call to mem_fn being ambiguous due to stdcall / non-stdcall overloading.
I can get mem_fn_stdcall_test.cpp to compile and pass with mingw g++ 3.4.4 if I take out the
#define BOOST_MEM_FN_ENABLE_STDCALL
line. I'm not sure why or how this works, but it does. :-)

Conrad Scott: ...
void test_mem_fn(IDirect3DDevice9 * const device) { boost::shared_ptr<IDirect3DDevice9> ptr( device, boost::mem_fn(&IDirect3DDevice9::Release) ); }
There's also the option of using struct com_deleter { template<class T> void operator()(T* p) const { p->Release(); } }; void test(IDirect3DDevice9 * const device) { boost::shared_ptr<IDirect3DDevice9> ptr( device, com_deleter() ); }

Peter Dimov wrote:
There's also the option of using
struct com_deleter { template<class T> void operator()(T* p) const { p->Release(); } };
void test(IDirect3DDevice9 * const device) { boost::shared_ptr<IDirect3DDevice9> ptr( device, com_deleter() ); } Many thanks for this suggestion Peter. I've moved to using this sort of mechanism for now (and thus also dropped the #define BOOST_MEM_FN_ENABLE_STDCALL).
All the best, Conrad
participants (2)
-
Conrad Scott
-
Peter Dimov