From 61061ff150208f28c3e95bcd0f79794a2e15a1c3 Mon Sep 17 00:00:00 2001 From: g Date: Wed, 26 Oct 2016 23:55:04 -0700 Subject: [PATCH] Added description of the operator[] caveats --- Doc/Manual/SWIGPlus.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 74d9c9083..e1bc49f9e 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -2766,6 +2766,16 @@ have to handle it like a normal function. For example: are ignored as well as conversion operators.

+
  • The index operator, operator[], is particularly difficult to overload due to the C++ +implementation. Specifically, the get and set operators in other languages typically are separated +into two methods such that additional logic can be packed into the operations; C# uses +this[type key] { get { ... } set { ... }}, Python uses +__getitem__ and __setitem__, etc. In C++, the setter only exists if the return +type of operator[] is a reference, and if the creator of the method wanted unique logic when +getting or setting a value, they need to use a +temporary proxy. +
  • +
  • The semantics of certain C++ operators may not match those in the target language.