How to create a coverage range bin using the set_covergroup_expression option?

In reply to snognog:

Consider creating a more generic covergroup, then creating an array of covergroups iterating over your ranges.

typedef struct {int low, high;} range_t;

range_t array[3] = { '{1,2}, '{3,5}. '{7,12} };

int value;

covergroup cg (range_t range);
  option.per_instance = 1;
  coverpoint value {
    bins b = {[range.low:range.high]};
  }
endgroup

cg cg_h[3]

foreach (array[r]) cg[r] = new(array[r]);