1
我有一个C++类,它提出了一个流畅接口,是这样的:如何使用boost :: python暴露流畅接口的属性?
class Foo
{
public:
int bar() const { return m_bar; };
Foo& bar(int value) { m_bar = value; return *this; };
private:
int m_bar;
};
我想包裹bar()
功能在我的Python类的属性。所以我写了:
class_<Foo>("Foo")
.add_property(
"bar",
(int (Foo::*)())&Foo::bar,
(Foo& (Foo::*)(int))&Foo::bar
)
;
但是,编译器抱怨的制定者,因为它返回一个Foo&
,而不是仅仅void
。
我也许可以用make_function
指定赎回策略但在这里我坚持:我不知道指定(我甚至不知道,如果这样的政策存在)的政策。
我能做些什么来解决这个问题?
以下是编译器输出:
/usr/include/boost/python/detail/invoke.hpp:88: error: no match for call to '(const boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<Foo&>) (Foo&)'
谢谢。
的最佳解决方案。 – 2011-06-12 05:04:14