cpp/numeric/random/discrete distribution

produces random integers on the interval, where the probability of each individual integer is defined as $w i/S$, that is the weight of the th integer divided by the sum of all  weights.

satisfies all requirements of.