On 6/18/07, Daniel Berger <djberg96 / gmail.com> wrote:
> Hi all,
>
> Is it possible to wrap the C++ STL stuff? Say, for example, vector?
>
> #include "ruby.h"
> #include <vector>
> using namespace std;
>
> struct cvector{
>     vector<VALUE> array(0);
> };
>
> void Init_cvector(){
>     VALUE cVector = rb_define_class("CVector", rb_cObject);
> }
>
> When I try to compile this (using g++ on OS X) I get:
>
> /usr/local/lib/ruby/1.8/i686-darwin8.9.1/intern.h:207: error: use of
> enum 'rb_thread_status' without previous declaration
> /usr/local/lib/ruby/1.8/i686-darwin8.9.1/intern.h:207: error: invalid
> type in declaration before ';' token
> cvector.c:6: error: expected identifier before numeric constant
> cvector.c:6: error: expected ',' or '...' before numeric constant
> cvector.c: In function 'void Init_cvector()':
> cvector.c:10: warning: unused variable 'cVector'
> make: *** [cvector.o] Error 1
>
> Thanks,
>
> Dan

Have you tried swig?  Gonzalo Garramu˝´ has done some work to make the
ruby<->STL interface better (faster and more STL functionality).  I've
also done similar python<->STL modifications for swig.  I'd love to
see all of this completed with full STL functionality (containers,
iterators, algorithms) and the big-O performance preserved.  C++ STL
is quite rich w/ a lot of thought put into big-O performance (great
when dealing with large datasets).