Opened 12 years ago

Closed 12 years ago

#4223 closed Bugs (fixed)

boost::python exception translator causes ambiguous call errors with Visual Studio 2010

Reported by: blaquee@… Owned by: Dave Abrahams
Milestone: Boost 1.43.0 Component: python USE GITHUB
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

There is an occasion where the use of the register_exception_translator template function causes: error C2668: 'boost::bind' : ambiguous call to overloaded function

the particular file and line are located here: https://svn.boost.org/trac/boost/browser/trunk/boost/python/exception_translator.hpp

Line 21, where the call to bind is not properly scoped to a namespace and causes the compiler to resolve incorrectly. The error looks like this:

D:\boost_1_42\boost/python/exception_translator.hpp(21): error C2668: 'boost::bind' : ambiguous call to overloaded function
1>          D:\boost_1_42\boost/bind/bind.hpp(1322): could be 'boost::_bi::bind_t<R,F,L> boost::bind<bool,boost::python::detail::translate_exception<ExceptionType,Translate>,boost::arg<I>,boost::arg<2>,Translate>(F,A1,A2,A3)'
1>          with
1>          [
1>              R=bool,
1>              F=boost::python::detail::translate_exception<WSException,init_module_wshook::WSExceptionTranslator>,
1>              L=boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::_bi::value<init_module_wshook::WSExceptionTranslator>>,
1>              ExceptionType=WSException,
1>              Translate=init_module_wshook::WSExceptionTranslator,
1>              I=1,
1>              A1=boost::arg<1>,
1>              A2=boost::arg<2>,
1>              A3=init_module_wshook::WSExceptionTranslator
1>          ]
1>          C:\Program Files\Microsoft Visual Studio 10.0\VC\include\xxbind1(323): or       'std::tr1::_Bind<_Result_type,_Ret,_BindN> std::tr1::bind<bool,boost::python::detail::translate_exception<ExceptionType,Translate>,boost::arg<I>,boost::arg<2>,Translate>(_Fty,_Arg0,_Arg1,_Arg2)' [found using argument-dependent lookup]
1>          with
1>          [
1>              _Result_type=bool,
1>              _Ret=bool,
1>              _BindN=std::tr1::_Bind3<std::tr1::_Callable_obj<boost::python::detail::translate_exception<WSException,init_module_wshook::WSExceptionTranslator>,false>,boost::arg<1>,boost::arg<2>,init_module_wshook::WSExceptionTranslator>,
1>              ExceptionType=WSException,
1>              Translate=init_module_wshook::WSExceptionTranslator,
1>              I=1,
1>              _Fty=boost::python::detail::translate_exception<WSException,init_module_wshook::WSExceptionTranslator>,
1>              _Arg0=boost::arg<1>,
1>              _Arg1=boost::arg<2>,
1>              _Arg2=init_module_wshook::WSExceptionTranslator
1>          ]
1>          while trying to match the argument list '(boost::python::detail::translate_exception<ExceptionType,Translate>, boost::arg<I>, boost::arg<I>, init_module_wshook::WSExceptionTranslator)'
1>          with
1>          [
1>              ExceptionType=WSException,
1>              Translate=init_module_wshook::WSExceptionTranslator
1>          ]
1>          and
1>          [
1>              I=1
1>          ]
1>          and
1>          [
1>              I=2
1>          ]
1>          wspluginmanager_python.cpp(179) : see reference to function template instantiation 'void boost::python::register_exception_translator<WSException,init_module_wshook::WSExceptionTranslator>(Translate,boost::type<T> *)' being compiled
1>          with
1>          [
1>              Translate=init_module_wshook::WSExceptionTranslator,
1>              T=WSException
1>          ]
1>

The line of code that would cause such an error is:

py::register_exception_translator<WSException>(WSExceptionTranslator());

namespace py = boost::python

The fix for this would be to properly use boost::bind at line 21 and cause it to resolve properly on Visual Studio 2010 RTM.

Thank you.

Change History (2)

comment:1 by anonymous, 12 years ago

Component: NonePython
Owner: set to Dave Abrahams
Version: Boost 1.44.0Boost 1.42.0

comment:2 by Steven Watanabe, 12 years ago

Resolution: fixed
Status: newclosed

(In [62198]) Explicitly qualify bind with boost::. Fixes #4223.

Note: See TracTickets for help on using tickets.