In reply to DK87:
Not according to the current LRM which says it can only be applied to arrays of integral types.
But all versions I tried support this as long as the with clause returns a type valid for the reduction operator.
module top;
class A;
rand bit[7:0] b;
endclass
A array[10];
initial begin
foreach(array[ii]) begin
array[ii] = new;
void'(array[ii].randomize());
$write("array[%0d]=%d ",ii,array[ii].b);
end
$display("\n sum = %d",array.sum() with (int'(item.b)));
end
endmodule
This requested in 0001690: Array reduction methods for non-integral types - Accellera Mantis