Too many operators

Oh, I totally underestimated the amount of operators required to make all the operations I planned for multidimensional array. For a one-dimensional array it's easy to specifiy: a range inside a one-dimensional aarray has a starting point and a size or length. Just operate on the elements in range (or outside, if you want a reversed range) and everythin's fine. Though you'd need to call operators specifically due to more than one parameter. It's really easy at all cause you probably only have one type for the range. Using twodimensional arrays becomes more work: How do you store a two-dimensional range? Either as a vector, as an array with two elements, as a scalar value representing an all-same vector or by specifying the parameters directly. The last possibility is a bad one, cause you a) need to specifiy each parameter by hand and b) you can't implement generalized. So as I already distilled, the best way to specify such vectors is to give a scalar value, an array of values (very useful if you want to hardcore values) or using an own struct. I could implement it simply by always converting to array/scalar content to a vector, but that requires creating a temporary etc and so. A bad idea if it's done in realtime. Converting it before is not an option, some libraris use arrays instead of vectors or even their own format. It doesn't make any sense to not include - it's too versatile and keeps it open to other interfaces etc and so on blabla.

It seems that the only real "solution" to this problem is that I need specify each version of the operator. Instead of one operator with only one type, you'd need four overloaded operators for two types and eight overloaded operators for three types. That's a SHITLOAD of operators! Imagine that! C++ gives you 29 operators (maybe I forgot some or so) you can use to combine to objects. It's a total of fucking 232 operators! Even if you write them all in a line, it's a bit of shame you only need to make so little changes. So I'm thinking about another solution, probably involving some kind of template meta programming to make classes with only functions gettin inserted inline during compile time. Yeah, so I can keep it down to only 29 single, component-wise operations. Hope I can also find a way to conveniently pass settings and so on, making it useful all kinds of other, more special functions.

But geez, 232 is aBIG number... I'd rather prefer going the hacky way this time, I think it's just too much annoying work to do for many many rather simply changes.

No comments: