fix!(eoBit): defaults to char for scalar type

Since STL's vector of bool is not a vector of bool, `swap`ing bool elements in an eoBit can lead to errors.
Using `char` is a saner default.

Potential BREAKING CHANGE.
This commit is contained in:
Johann Dreo 2024-08-19 09:49:08 +02:00
commit 55b2f57d19
5 changed files with 9 additions and 9 deletions

View file

@ -60,12 +60,12 @@ Example of a complete test program that use various bitstrings operators:
Based on STL's std::vector<bool> specialization.
*/
template <class FitT, class ScalarT = bool>
template <class FitT, class ScalarT = char>
class eoBit: public eoVector<FitT, ScalarT>
{
public:
using ScalarType = ScalarT;
using ScalarType = ScalarT;
using eoVector< FitT, ScalarType >::begin;
using eoVector< FitT, ScalarType >::end;

View file

@ -68,7 +68,7 @@ eoInit<EOT> & do_make_genotype(eoParser& _parser, eoState& _state, EOT, float _b
// Then we can built a bitstring random initializer
// based on boolean_generator class (see utils/rnd_generator.h)
eoBooleanGenerator<bool> * gen = new eoBooleanGenerator<bool>(_bias);
eoBooleanGenerator<char> * gen = new eoBooleanGenerator<char>(_bias);
_state.storeFunctor(gen);
eoInitFixedLength<EOT>* init = new eoInitFixedLength<EOT>(theSize, *gen);
// store in state

View file

@ -115,7 +115,7 @@ inline bool eoUniformGenerator<bool>::operator()(void)
to easily generate random booleans with a specified bias
\ingroup bitstring
*/
template<class T=bool>
template<class T=char>
class eoBooleanGenerator : public eoRndGenerator<T>
{
public :