C++ vs D: Default param values and struct to array casting

a11e99z black80 at bk.ru
Fri Sep 6 11:35:59 UTC 2019


On Friday, 6 September 2019 at 09:14:31 UTC, Andrew Edwards wrote:
> C++ allows the for following:
>
> struct Demo
> {
> 	float a, b, c, d;
> 	Demo() { a = b = c = d = 0.0f; }
> 	Demo(float _a, float _b, float _c, float _d) {
> 		a = _a;
> 		b = _b;
> 		c = _c;
> 		d = _d;
> 	}
> 	float  operator[] (size_t i) const { return (&a)[i]; } //[3]
> 	float& operator[] (size_t i) { return (&a)[i]; } //[4]
> }
>

https://dlang.org/spec/simd.html

also probably u can do https://run.dlang.io/is/WMQE93



More information about the Digitalmars-d-learn mailing list