fix: add template to eoBooleanGenerator

In order to be able to generate boolean within int types.
This commit is contained in:
Johann Dreo 2020-10-09 14:09:45 +02:00
commit 3d6821a97c

View file

@ -115,15 +115,16 @@ inline bool eoUniformGenerator<bool>::operator()(void)
to easily generate random booleans with a specified bias to easily generate random booleans with a specified bias
\ingroup bitstring \ingroup bitstring
*/ */
class eoBooleanGenerator : public eoRndGenerator<bool> template<class T=bool>
class eoBooleanGenerator : public eoRndGenerator<T>
{ {
public : public :
eoBooleanGenerator(float _bias = 0.5, eoRng& _rng = rng) : bias(_bias), gen(_rng) {} eoBooleanGenerator(float _bias = 0.5, eoRng& _rng = rng) : bias(_bias), gen(_rng) {}
bool operator()(void) { return gen.flip(bias); } T operator()(void) { return gen.flip(bias); }
private : private :
float bias; float bias;
eoRng& gen; eoRng& gen;
}; };
/** /**