Struct Flattening
dsimcha
dsimcha at yahoo.com
Tue Apr 21 21:42:27 PDT 2009
I'm working on porting dstats to ranges and I've run across an interesting
problem. I've defined a range that I'm going to use for joint entropy, etc.
It's basically a tuple with some special properties. Let's say I have a
template struct:
struct Joint(T...) {
T ranges;
}
It's built with:
SomeType joint(T...)(T args) { // do stuff. }
When one of the arguments is a Joint, I want it to flatten. For example,
Joint!(uint[], uint[]) r1;
uint[] r2;
auto result = joint(r1, r2);
// result is a Joint!(uint[], uint[], uint[]), not a
// Joint!(Joint!(uint[], uint[]), uint[]).
Is there an easy metaprogramming trick that I've overlooked to make stuff
flatten like this?
More information about the Digitalmars-d
mailing list