[英]Export functions which returns a reference
我想導出到python模塊(用boost.python庫用c ++編寫)這樣的功能:
Vec2<Type> &normalize ()
Type dot(const Vec2<Type> &vector) const
這些是模板類Vec2
的成員。 這是我的導出代碼:
bp::class_< Vec2<int> >("Vec2i", bp::init<int, int>())
.def("Length", &Vec2<int>::length)
.def("Dot", &Vec2<int>::dot, bp::return_internal_reference<>());
//.def("Normalize", &Vec2<int>::normalize);
Length
方法編譯成功,但是Dot
和Normalize
返回相同的錯誤(在編譯過程中):
error: no matching function for call to ‘boost::python::class_<Vec2<int> >::def(const char [4], <unresolved overloaded function type>, boost::python::return_internal_reference<>)’
我做錯了什么?
UPD
真正的類名稱是: CL_Vec<Type>
,這是docs 。
當編譯器說:
<unresolved overloaded function type>
查看您的成員指針或函數指針(&Vec2 :: dot),看看它是否指向一組重載函數(應該)。 在這種情況下,您可能需要針對特定的成員指針或函數指針類型(包括函數參數類型)的顯式static_cast <>。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.