
I have uploaded a small prototype that demonstrates the syntax mentioned in the thread below. It is in the Vault under Math - Geometry as swizzle_demo.zip. http://article.gmane.org/gmane.comp.lib.boost.devel/149076/match=geometry+ve... Here's a small example showing its use: float4 b(1, 2, 3, 4); float4 a = b.xxxx(); // a is now 1, 1, 1, 1 a = b.wwwz(); // a is now 4, 4, 4, 3 a = b.yzzw(); // a is now 2, 3, 3, 4 a = b.wzyx(); // a is now 4, 3, 2, 1 float4 c(10, 20, 30, 40); c.yz() = b.zy(); // c is now 10, 3, 2, 40 This mimics Cg, HLSL, and GLSL syntax closely. The swizzle syntax is implemented as function calls so that it doesn't increase the size of the vector struct (important for using those structs directly for graphics API calls). The prototype code does not implement arithmetic operators for simplicity's sake, but my local copy has it implemented. This isn't meant as a full library, only a demonstration showing that the swizzle syntax can be achieved rather simply using the Boost PP and TypeTraits libraries. One item that could be changed is the multiple template parameters to the classes. In the discussion that took place during the review of Andy Little's library the prospect of heterogeneous vectors took place. In my opinion heterogeneous vectors work with little expense to the library writer and transparently to the user. It would also "just work" with Andy's Quan library, or the other Units library being developed. This is pretty off-topic for the syntax that I am demonstrating, I just wanted to mention that I hadn't removed it from this demo. It is in no way necessary, but removal would require the macros to be changed a little bit. I have only compiled using VS 7.1 and 8.0. I am by no means a PP or template guru, so I would welcome your thoughts and critiques. --Michael Fawcett