static assert(areCombinable!(int, int, int)); static assert(areCombinable!(float[], int, char[])); static assert(areCombinable!(string, int, int)); // Works with string because: import std.traits: CommonType; import std.range: ElementType; static assert(is(CommonType!(ElementType!string, int) == uint)); struct A {} static assert(!areCombinable!(A, int, int)); static assert(!areCombinable!(A[], int[])); static assert( areCombinable!(A[], A[])); static assert( areCombinable!(A[], A[], A)); static assert(!areCombinable!(int[], A));
bolts.meta.Flatten
Tells you if a list of types, which are composed of ranges and non ranges, share a common type after flattening the ranges (i.e. ElementType)
This basically answers the question: $(Can I combine these ranges and values into a single range of a common type?)