How can I store objects in arrays?


I have multiple objects, named M1, M2, M3…, that have been injected into a chaiscript. I’d like to store them in an array so that I can refer to them using an index. However, when I tried to write

meters = [M1, M2, M3];

I got errors about no clone or copy constructors being available. But I don’t want copies, I really just want the references. I tried

meters = [&M1, &M2, &M3]

but the compiler didn’t like that either.

Any way to do this?



You’ll want to do something like:

var meters=[]

To explicitly not make a clone when adding the object to the vector.


Thank you - that worked perfectly