现在的位置: 首页 > 综合 > 正文

Boost::Python很好很强大!

2013年02月10日 ⁄ 综合 ⁄ 共 251字 ⁄ 字号 评论关闭
例如在Python里面可以这样写:
def f(x, y):
if (y == 'foo'):
x[3:7] = 'bar'
else:
x.items += y(3, x)
return x

def getfunc():
return f;


用了Boost::Python以后,可以这样写:

object f(object x, object y) {
if (y == "foo")
x.slice(3,7) = "bar";
else
x.attr("items") += y(3, x);
return x;
}
object getfunc() {
return object(f);
}
 

抱歉!评论已关闭.