通过 SWIG 从 Ruby 调用 Boost?
假设我想从 Ruby 代码调用一个或多个 boost 库函数。我想这样做的例子有很多,但最近我想使用 Boost Graph 库来进行高效的图形处理。我认为最常建议执行此操作的方法是使用 SWIG。有没有人浏览过并生成 Boost 库的 SWIG 包装器?这实际上是与 Boost 互操作的最佳方式吗? Boost 的哪些部分无法通过 SWIG 访问,因为它们需要不受支持的 C++ 功能才能工作?
Suppose I want to call one or more boost library functions from Ruby code. There are many examples of times where I'd want to do this, but most recently I want to use the Boost Graph library for efficient graph processing. I think the way most often suggested for doing this is to use SWIG. Has anyone gone through and generated SWIG wrappers for the Boost library? Is this in fact the best way to interoperate with Boost? What parts of Boost cannot be accessed through SWIG because they require unsupported C++ features to work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不能说我已经专门为 Boost 库生成了包装器,但我已经为我自己的模板类生成了包装器。
只要您记住 SWIG 将使用
%template
指令。如上面链接的文档中所述:
使用该指令,您的
intvector
将如下所示:I can't say I have generated wrappers for the Boost libraries specifically, but I have done so for my own templated classes.
This is perfectly doable as long as you keep in mind that SWIG will wrap specific template instantiations using the
%template
directive.As stated in the documentation linked above:
With the directive your
intvector
would look something like this: