diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h index 6cddf5ed..fb8b11d4 100644 --- a/include/libcmaes/eigenmvn.h +++ b/include/libcmaes/eigenmvn.h @@ -47,12 +47,30 @@ namespace Eigen { namespace internal { template - struct scalar_normal_dist_op + class scalar_normal_dist_op { +private: + void swap(scalar_normal_dist_op &other) { + std::swap(rng, other.rng); + std::swap(norm, other.norm); + } +public: static std::mt19937 rng; // The uniform pseudo-random algorithm mutable std::normal_distribution norm; // gaussian combinator EIGEN_EMPTY_STRUCT_CTOR(scalar_normal_dist_op) + + scalar_normal_dist_op &operator=(scalar_normal_dist_op &&other) + { + if (this != &other) { + swap(other); + } + return *this; + } + + scalar_normal_dist_op(scalar_normal_dist_op &&other) { + *this = std::move(other); + } template inline const Scalar operator() (Index, Index = 0) const { return norm(rng); }