areFlatteninglyCombinable

Is true iff 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?.

template areFlatteninglyCombinable (
Values...
) {
enum areFlatteninglyCombinable;
}

Examples

1 static assert(areFlatteninglyCombinable!(int, int, int));
2 static assert(areFlatteninglyCombinable!(float[], int, char[]));
3 static assert(areFlatteninglyCombinable!(string, int, int));
4 
5 // Works with string because:
6 import std.traits : CommonType;
7 import std.range.primitives : ElementType;
8 
9 static assert(is(CommonType!(ElementType!string, int) == uint));
10 
11 struct A
12 {
13 }
14 
15 static assert(!areFlatteninglyCombinable!(A, int, int));
16 static assert(!areFlatteninglyCombinable!(A[], int[]));
17 static assert( areFlatteninglyCombinable!(A[], A[]));
18 static assert( areFlatteninglyCombinable!(A[], A[], A));
19 static assert(!areFlatteninglyCombinable!(int[], A));

See Also

meta_ex.FlattenedRanges

Meta