I have a class (for the mathematically inclined, it's a tensor class that allows me to work with tensors of any rank and dimension), and I'm trying to set up assignment in a particular way, but having trouble.
The idea comes from the vector class. With that, you can retrieve a particular element using [iline]vector.at(n)[/iline] and also set that element by using [iline]vector.at(n)=value[/iline].
Currently, the class has a member [iline]operator(int i, ...)[iline] that will retrieve the value I want from the array *T where all the elements are stored, but in order to set them I have to call tensor.T[index]. The problem is that index isn't physically meaningful (to get index from the coordinates requires a messy sum), whereas calling tensor(i, ...) will grab the proper coordinates. I've tried overloading with [iline]operator(FLOAT val, int i, ...)[iline] where val is the value I want to set it to, but gcc complains about ambiguity (I would say from recasting, as you can pass an int as a float without error and such).
The long and short of it is I'd like to know how I can define a member that operates like the vector at()= method.
Note I've tried looking at the source and have attempted to recreate it with no luck.