I am using Swig to use C ++ in ruby โโand currently I have made a simple example of the david.h file
#include <stdio.h> class David { public: David(int x) { this->x = x; } void announce() { printf("David %d\n", x); } int x; };
And another swig file like this
%module "david" %{ #include <libdavid.h> %} class David { public: David(int x); void announce(); int x; };
My extconf.rb looks like this
require 'mkmf' system('swig -c++ -ruby libdavid.i') or abort create_makefile('david')
It helps me to execute an extremely simple example in a ruby โโlike this
2.2.1 :001 > a=David::David.new(42) =>
Now I tried a lot of time, but I just can't figure out how to use set from C ++ stl, as shown in the example here . It would be very nice if someone could help me with how I could create a set of stl integers or maybe a vector and show how to insert and erase methods for this set / vector. Simple code samples would be very useful not only for me, but also for many people who may encounter this in the future.
This is just a personal request, feel free to skip this if you are busy. Honestly, I have been using stack overflows for a long time, but gradually I am starting to get discouraged in the community. I asked several questions, and I did not have satisfactory answers, No votes, no votes, nothing, I just do not get answers. It amazes me that extremely simple questions that can be answered in a simple Google search are often very popular, and important questions from new users are either voted heavily or completely ignored. I understand that the community is not doing anything. But I would be very grateful if anyone could explain the possible reasons for this.
thanks
source share