Enum member areCombinable

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)

enum areCombinable(Values...) = !is(CommonType!(Flatten!Values) == void);

This basically answers the question: I combine these ranges and values into a single range of a common type?

See also



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));