August 08, 2013 Multiple alias for multiple functions? | ||||
---|---|---|---|---|
| ||||
I want to make a simple Vector struct class: struct Vector { alias _data this; alias data!0 x, width; alias data!1 y, height; private: @property float data(int i)() { return _data[i]; } @property void data(int i)(float value) { _data[i] = value; } float[2] _data; } But I get two similar errors: Vector.data matches more than one template declaration, vector.d(9):data(int i)() and vector.d(13):data(int i)(float value) I see that it might cause problems to have ambiguous aliases, but does anyone know how I might implement this? Should I remove the struct and just make @property x for float[2] and the others? |
August 08, 2013 Re: Multiple alias for multiple functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Borislav Kosharov | On Thursday, 8 August 2013 at 20:14:58 UTC, Borislav Kosharov wrote:
> I want to make a simple Vector struct class:
>
> struct Vector {
> alias _data this;
> alias data!0 x, width;
> alias data!1 y, height;
>
> private:
> @property float data(int i)() {
> return _data[i];
> }
>
> @property void data(int i)(float value) {
> _data[i] = value;
> }
>
> float[2] _data;
> }
>
> But I get two similar errors:
> Vector.data matches more than one template declaration, vector.d(9):data(int i)() and vector.d(13):data(int i)(float value)
>
> I see that it might cause problems to have ambiguous aliases, but does anyone know how I might implement this? Should I remove the struct and just make @property x for float[2] and the others?
template data(int i) {
@property float data() {
return _data[i];
}
@property void data(float value) {
_data[i] = value;
}
}
|
Copyright © 1999-2021 by the D Language Foundation