Template class with dispatched properties

Ali Çehreli acehreli at yahoo.com
Mon Nov 25 23:01:43 PST 2013


On 11/07/2013 10:05 PM, Philippe Sigaud wrote:
> On Fri, Nov 8, 2013 at 5:55 AM, Ross Hays <throwaway at email.net> wrote:
>
>> And let me say that I really do like that this works in D. I can't imagine
>> doing anything like this in C++ (which is what I used primarily in the
>> past).
>>
>> The only reason I joke about it being useless is it really only supports
>> vectors of length 2 or 3 (technically 1 as well but that is not really a
>> vector) and at that point I am tempted to say it is more efficient to just
>> make a Vector2!float class or something of the sorts.
>>
>
> Then the next step is to allow swizzling (sp?) :-)
>
> auto myVec = yourVec.yzx; // myVec.x = yourVec.y, myVec.y = yourVec.z,
> myVec.z = yourVec.x;
>
> auto myVec2 = yourVec.xxx; // and so on
>

Manu Evans had reported either during his talk at DConf 2013 or during 
private conversations at the same conference that the technique has been 
used at Remedy Games.

Ali



More information about the Digitalmars-d-learn mailing list