[C++-sig] Strange Boost.Python-related compile error
Lawrence Spector
Lawrence.Spector at CanfieldSci.com
Tue Jul 24 17:01:25 CEST 2007
Sorry about that example. I must've been in a daze when I posted that. I copy and pasted from two different parts of code and tried to make the example more generic, but... uhh, anyway what I posted yesterday doesn't make any sense.
So, as you requested, here's a sample that demonstrates the problem.
// Very simple class to demonstrate issue:
#include <string>
#include <boost/variant.hpp>
typedef boost::variant<std::wstring> ReturnType;
class TestClass
{
public:
virtual const ReturnType getValue() const;
}; // end Derived
// Generated Boost.Python code from Py++
#include "boost/python.hpp"
namespace bp = boost::python;
struct TestClass_wrapper : TestClass, bp::wrapper< TestClass > {
TestClass_wrapper(TestClass const & arg )
: TestClass( arg )
, bp::wrapper< TestClass >(){
// copy constructor
}
TestClass_wrapper()
: TestClass()
, bp::wrapper< TestClass >(){
// null constructor
}
virtual ::ReturnType const getValue( ) const {
if( bp::override func_getValue = this->get_override( "getValue" ) )
return func_getValue( ); // **** This is the error line
else
return this->TestClass::getValue( );
}
::ReturnType const default_getValue( ) const {
return TestClass::getValue( );
}
};
BOOST_PYTHON_MODULE(pyplusplus){
bp::class_< TestClass_wrapper >( "TestClass" )
.def(
"getValue"
, &::TestClass::getValue
, &TestClass_wrapper::default_getValue );
}
Output:
1>------ Build started: Project: VariantCompileError, Configuration: Debug Win32 ------
1>Compiling...
1>BpErr.cpp
1>c:\3rdparty\boost_1_34_0\boost\python\detail\caller.hpp(52) : warning C4244: 'return' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data
1>c:\3rdparty\boost_1_34_0\boost\variant\variant.hpp(1273) : error C2665: 'boost::detail::variant::make_initializer_node::apply<BaseIndexPair,Iterator>::initializer_node::initialize' : none of the 2 overloads could convert all the argument types
1> with
1> [
1> BaseIndexPair=boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>,
1> Iterator=boost::mpl::l_iter<boost::mpl::list1<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>>
1> ]
1> c:\3rdparty\boost_1_34_0\boost\variant\detail\initializer.hpp(89): could be 'int boost::detail::variant::make_initializer_node::apply<BaseIndexPair,Iterator>::initializer_node::initialize(void *,const std::basic_string<_Elem,_Traits,_Ax> &)'
1> with
1> [
1> BaseIndexPair=boost::mpl::pair<boost::detail::variant::initializer_root,boost::mpl::int_<0>>,
1> Iterator=boost::mpl::l_iter<boost::mpl::list1<std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>>,
1> _Elem=wchar_t,
1> _Traits=std::char_traits<wchar_t>,
1> _Ax=std::allocator<wchar_t>
1> ]
1> while trying to match the argument list '(void *, const boost::python::detail::method_result)'
1> c:\3rdparty\boost_1_34_0\boost\variant\variant.hpp(1342) : see reference to function template instantiation 'void boost::variant<T0_>::convert_construct<const T>(T &,int,boost::mpl::false_)' being compiled
1> with
1> [
1> T0_=std::wstring,
1> T=boost::python::detail::method_result
1> ]
1> c:\work\sandbox\boost\python\variantcompileerror\src\bperr.cpp(38) : see reference to function template instantiation 'boost::variant<T0_>::variant<boost::python::detail::method_result>(const T &)' being compiled
1> with
1> [
1> T0_=std::wstring,
1> T=boost::python::detail::method_result
1> ]
1>Build log was saved at "file://c:\Work\Sandbox\Boost\Python\VariantCompileError\VariantCompileErrorVC80\Debug\BuildLog.htm"
1>VariantCompileError - 1 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any ideas what's going on?
Thanks,
Lawrence
More information about the Cplusplus-sig
mailing list