I’ve got a bunch of objects that are, intentionally, not copyable. For the same of simplicity lets just say they’re of type
In ChaiScript I can do:
var x = X(); SomeCppFun(x);
just fine assuming
SomeCppFun accepts a
shared_ptr<X>. However, I have a function that accepts a
vector<shared_ptr<X>> so I want to be able to do this:
var x1 = X(); var x2 = X(); // dies here var xs = [x1, x2]; SomeCppFun(xs);
But I get errors on
[x1, x2] that say, “Can not find appropriate ‘clone’ or copy constructor for vector elements” during evaluation". What I want is for ChaiScript to be putting references (shared_ptr’s) to
[x1, x2] as references to
x2 (that is modifying
xs would modify
x1) I assumed ChaiScript could create the array without copying the objects, but that appears not to be the case.
Is there any way to create arrays of references/pointers to non-copyable objects in ChaiScript?