Skip to content

binomial_distribution doesn't work with unsigned integer types #150

@KRM7

Description

@KRM7

Code using boost::binomial_distribution fails to compile if the template argument is an unsigned integer type, due to an ambiguous call to abs in the implementation of generate().
https://godbolt.org/z/MKKGz3b4r

#include <boost/random.hpp>
#include <random>
#include <cstddef>

std::mt19937_64 prng(0);
boost::random::binomial_distribution<uint64_t> dist;

uint64_t test(uint64_t num) {
    return dist(prng);
}

The ambiguous call is here:

RealType km = abs(k - m);

Is this the intended behaviour? I haven't seen anything in the docs that would mention that the template argument must be signed, and std::binomial_distribution supports unsigned integer types.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions