digitalmars.D.learn - Expression template in D struct
- The Anh Tran (11/11) May 06 2009 Hi,
- Trass3r (2/6) May 06 2009 You calculate where to point the gun at compile-time?
- The Anh Tran (10/17) May 06 2009 No :)
- Simen Kjaeraas (11/27) May 07 2009 If you want something capable of processing the above, it will
Hi, I'm converting my pet project from C++ to D. It is an aimbot game cheat. One of my C++ struct is Vector3. It is a wrapper from D3DXVECTOR3. I would like to use expression template to calculate where to point the gun. In C++, it is provided by boost::proto or boost::ublas. My naive implementation (in fact, "copy&paste" from c++ book "thinking in c++") refused to compile. I've searched dsource.org; the nearest match is Don's BLADE library. Is there any tutorial, or simpler way to do expression in D; without building AST as in BLADE? Thanks.
May 06 2009
The Anh Tran schrieb:One of my C++ struct is Vector3. It is a wrapper from D3DXVECTOR3. I would like to use expression template to calculate where to point the gun. In C++, it is provided by boost::proto or boost::ublas.You calculate where to point the gun at compile-time?
May 06 2009
Trass3r wrote:The Anh Tran schrieb:No :) I would like to learn D template programming; all i need is just a compile-time expression. vPredicted = vEnd + (((ProjectileSpeed^2 * |vStart-vEnd|^2 - |(vStart-vEnd) X Velocity | ^2) ^ 0.5 + (vStart-vEnd) * vVelocity) / (ProjectileSpeed^2 - |vVelocity|^2)) * vVelocity vXYZ is a struct, re-present 3D coordinate / velocity vector.One of my C++ struct is Vector3. It is a wrapper from D3DXVECTOR3. I would like to use expression template to calculate where to point the gun. In C++, it is provided by boost::proto or boost::ublas.You calculate where to point the gun at compile-time?
May 06 2009
On Thu, 07 May 2009 03:31:46 +0200, The Anh Tran <trtheanh gmail.com> wrote:Trass3r wrote:If you want something capable of processing the above, it will probably have to work along the lines of BLADE: use a CTFE function to parse the string and turn it into whatever code you prefer it to be. I do not believe there is such a library in existence, though I may of course be wrong. As for which functions are CTFE-able: http://digitalmars.com/d/2.0/function.html#interpretation -- SimenThe Anh Tran schrieb:No :) I would like to learn D template programming; all i need is just a compile-time expression. vPredicted = vEnd + (((ProjectileSpeed^2 * |vStart-vEnd|^2 - |(vStart-vEnd) X Velocity | ^2) ^ 0.5 + (vStart-vEnd) * vVelocity) / (ProjectileSpeed^2 - |vVelocity|^2)) * vVelocity vXYZ is a struct, re-present 3D coordinate / velocity vector.One of my C++ struct is Vector3. It is a wrapper from D3DXVECTOR3. I would like to use expression template to calculate where to point the gun. In C++, it is provided by boost::proto or boost::ublas.You calculate where to point the gun at compile-time?
May 07 2009