[C++-sig] Re: Getting the pointer for a member operator
Nicodemus
nicodemus at esss.com.br
Fri Apr 29 23:05:43 CEST 2005
Vladimir Sukhoy wrote:
>>Problem is that this is broken under MSVC.NET 2003. The compiler complains
>>with:
>>
>I tried similar with .NET 2003 compiler - it works, and I cannot reproduce
>this error! The full module code is:
>
><snip code>
>
Thanks for trying it Vladimir! Indeed the above code does work. Since
the error message is pretty specific, I assumed the error was on that
line. If I tried to post a reproductible test case, as I should, I would
learn that the error only shows in the following code:
//----------------------------------------
#include <boost/python.hpp>
using namespace boost::python;
namespace operators
{
struct C
{
operator int() const { return 1; }
operator const char*() { return "C"; }
};
}
BOOST_PYTHON_MODULE(_ace)
{
class_< operators::C >("C", init< >())
.def("__int__", &operators::C::operator int) // comment this line
.def("__str__", &operators::C::operator const char*)
;
}
//----------------------------------------
If you comment the marked line, the code compiles fine. Otherwise, it
gives this error:
op2.cpp(16) : error C2833: 'operator const' is not a recognized operator
or type
Does anyone know what is going on?
More information about the Cplusplus-sig
mailing list