On 10 December 2015 at 15:54, Sam Kellett
[snip]
This problem does not have a good solution in C++, any chosen operator has
drawbacks. That said, I wouldn't support ref(v).X() for accessing the X element of a vector, or ref(v).XY() for swizzling.
what about ref(v)[xy]? wrapping the custom type in a ref call alleviates the restriction against the () and [] operators.
or maybe: swizzle(v, xy)
i also wonder if this might be possible: ref(v)->xy assuming the xy is a field in an enum that the operator-> returns. whether or not there's anyway of intercepting that to actually do the swizzle though i'm not sure...
a couple more thoughts about this... what namespace is your comma operator in? it could be placed in an extra namespace which users can explicitly pull in if they prefer the super compact (albeit controversial) syntax and then anybody else could stick with a normal free function (like my swizzle(v, xy) above) which would be in the normal qvm namespace