D - opIndex
- Matthew Wilson (13/13) Dec 18 2003 The examples given on the site have the binary opIndex returning a value...
- Walter (6/18) Dec 19 2003 of
The examples given on the site have the binary opIndex returning a value of the same type as the second parameter, as in struct A { int opIndex(int i); int opIndex(int i, int value); } Is this so that it can be reused in expressions such as the following A a1 = ... A a2 = ... a1[10] = a2[5] = 3; I presume the author returns the new value, rather than the previous value? Matthew
Dec 18 2003
"Matthew Wilson" <matthew.hat stlsoft.dot.org> wrote in message news:brs079$2n2g$2 digitaldaemon.com...The examples given on the site have the binary opIndex returning a valueofthe same type as the second parameter, as in struct A { int opIndex(int i); int opIndex(int i, int value); } Is this so that it can be reused in expressions such as the following A a1 = ... A a2 = ... a1[10] = a2[5] = 3; I presume the author returns the new value, rather than the previousvalue? The return type and value from opIndex is whatever the programmer specifies it to be.
Dec 19 2003