Hello,
I am trying to bind operator for my custom class, Here is the code:
class TestClass : public SimpleDataType { public: TestClass() {} ~TestClass() override {} void bind() override { SimpleDataType::bind(); bindStlContainer(vec); } void bindInterface() override { bindBracketOperator(int, TestClass, int); bindOperator([], TestClass, "int (int index)"); } int operator[](int index) { return vec[index]; } private: std::vector<int> vec = { 1, 2, 3 }; };
When I use the operator[] in flexsim(index = 0), both bindBracketOPeraor and bindOPerator throw exception for "vector subscript out of range", as the value of vec shown in flexsim is exactly {1, 2 ,3}, so how can I bind the operator[] by the two different ways(bindBracketOPeraor and bindOPerator)?
Thanks!