question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Mischa Spelt answered

Binding bracket operator

Hi @jordan.johnson,

Could you help me bind a bracket operator in my custom class? By looking at the macro definition, I figured that something like this should work:

  1. void MyObjectArray::bindInterface() const
  2. {
  3. bindTypedProperty( length, int, &MyObjectArray::GetLength, nullptr );
  4. // ...
  5. bindBracketOperator( MyObject, MyObjectArray, int );
  6. }
  7. int MyObjectArray::GetLength() const
  8. {
  9. return this->length;
  10. }
  11. MyObject MyObjectArray::operator[]( int index ) const
  12. {
  13. return this->objects[index];
  14. }

but when I try to use it in FlexSim I get

  1. Could not resolve correct operator for [] operation. Left side type is MyObjectArray, right type is int

and also the [...] does not show up in code completion.
Is there a bug or did I misinterpret the arguments to bindBracketOperator?

Thanks!

FlexSim 17.1.2
module sdkdot syntaxbracket operator
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Mischa Spelt avatar image
2 Likes"
Mischa Spelt answered

Never mind, I figured it out. The code is correct, I just forgot to

  1. bindClass( MyObject )

so probably FlexSim was confused about that.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.