Extended the documentation for octave operator overloading

Octave has more operators than C++. These operators can be overloaded for
the type swig_ref using the standard Octave Object Oriented Programming mechanism.
This is now added to the documentation.
This commit is contained in:
Markus Friedrich 2022-09-18 20:19:39 +02:00
commit d1b7765838

View file

@ -625,6 +625,16 @@ On the C++ side, the default mappings are as follows:
Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.
</p>
<p>
Octave has several operators for which no corresponding C++ operators exist. For example, the Octave code
</p>
<div class="targetlang"><pre>
x=[a,b,c];
</pre></div>
<p>
calls the Octave operator <tt>horzcat</tt> of the class of <tt>a</tt>. Hence, if <tt>a</tt> is of type <tt>swig_ref</tt> you can write an overload for this operator for your wrapped C++ class by placing a file <tt>@swig_ref/horzcat.m</tt> in the Octave load path (like for every Octave class, see <a href="https://docs.octave.org/latest/Creating-a-Class.html">Creating a Class</a>). This Octave function file is then called whenever the above Octave code is executed for a variable of type <tt>swig_ref</tt>.
</p>
<H3><a name="Octave_nn19">30.3.10 Class extension with %extend</a></H3>