digitalmars.D.learn - static array in templated struct/class
- ddos (12/12) Aug 05 2014 alias Vec4f = TVector!(float,4);
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (11/23) Aug 05 2014 Can you show the complete code? I cannot reproduce this with
- Daniel Gibson (2/28) Aug 05 2014 struct vs class?
- ddos (4/30) Aug 05 2014 http://pastebin.com/34sbffSa
- Philippe Sigaud via Digitalmars-d-learn (9/10) Aug 05 2014 Your problem comes from lengthSquared:
- ddos (5/19) Aug 05 2014 i wasn't intentionally creating a functionpointer, i just liked
alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the following errors, but why? struct Vector.TVector!(float, 4).TVector no size yet for forward reference struct Vector.TVector!(float, 3).TVector no size yet for forward reference
Aug 05 2014
On Tuesday, 5 August 2014 at 18:36:35 UTC, ddos wrote:alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the following errors, but why? struct Vector.TVector!(float, 4).TVector no size yet for forward reference struct Vector.TVector!(float, 3).TVector no size yet for forward referenceCan you show the complete code? I cannot reproduce this with either latest DMD git, DMD 2.065, or LDC 0.13.0: alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); struct TVector(T,int n) { T[n] val; } Vec3f a; Vec4f b;
Aug 05 2014
Am 05.08.2014 21:13, schrieb "Marc Schütz" <schuetzm gmx.net>":On Tuesday, 5 August 2014 at 18:36:35 UTC, ddos wrote:struct vs class?alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the following errors, but why? struct Vector.TVector!(float, 4).TVector no size yet for forward reference struct Vector.TVector!(float, 3).TVector no size yet for forward referenceCan you show the complete code? I cannot reproduce this with either latest DMD git, DMD 2.065, or LDC 0.13.0: alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); struct TVector(T,int n) { T[n] val; } Vec3f a; Vec4f b;
Aug 05 2014
On Tuesday, 5 August 2014 at 19:13:31 UTC, Marc Schütz wrote:On Tuesday, 5 August 2014 at 18:36:35 UTC, ddos wrote:http://pastebin.com/34sbffSa thx for your help :) ! i use DMD 2.065 btwalias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the following errors, but why? struct Vector.TVector!(float, 4).TVector no size yet for forward reference struct Vector.TVector!(float, 3).TVector no size yet for forward referenceCan you show the complete code? I cannot reproduce this with either latest DMD git, DMD 2.065, or LDC 0.13.0: alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); struct TVector(T,int n) { T[n] val; } Vec3f a; Vec4f b;
Aug 05 2014
http://pastebin.com/34sbffSaYour problem comes from lengthSquared: public auto lengthSquared = function () => val.reduce!((a,b) => a + b*b); That's an unusual way to define a method. Any reason why you are using a pointer to a function as a member? Do you need to be able to redefine it at runtime? I guess that in this case, the compiler cannot determine its return type and/or its size? I'd use: public auto lengthSquared () { return val.reduce!((a,b) => a + b*b);}
Aug 05 2014
i wasn't intentionally creating a functionpointer, i just liked the syntax x3 ... but i guess i should read into it now :) thx for you help ! On Tuesday, 5 August 2014 at 19:51:33 UTC, Philippe Sigaud via Digitalmars-d-learn wrote:http://pastebin.com/34sbffSaYour problem comes from lengthSquared: public auto lengthSquared = function () => val.reduce!((a,b) => a + b*b); That's an unusual way to define a method. Any reason why you are using a pointer to a function as a member? Do you need to be able to redefine it at runtime? I guess that in this case, the compiler cannot determine its return type and/or its size? I'd use: public auto lengthSquared () { return val.reduce!((a,b) => a + b*b);}
Aug 05 2014