rvalue references

Namespace via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 8 13:17:33 PDT 2015


> One useful case for me:
>
> static Mat4 transform()(const auto ref Vec3 pos, const auto ref 
> Vec3 scale, const auto ref Quat rot)
> {
>     Mat4 m = Mat4(rot.matrix, 1);
>
>     m.m00 *= scale.x;
>     m.m01 *= scale.x;
>     m.m02 *= scale.x;
>
>     m.m10 *= scale.y;
>     m.m11 *= scale.y;
>     m.m12 *= scale.y;
>
>     m.m20 *= scale.z;
>     m.m21 *= scale.z;
>     m.m22 *= scale.z;
>
>     m.m30 = pos.x;
>     m.m31 = pos.y;
>     m.m32 = pos.z;
>
>     return m;
> }
>
> Currently, my choices are template bloat, or pointless copying.
>
>   Bit

Yes, the same goes for Dgame.


More information about the Digitalmars-d mailing list