From 1e4d61adc648287d8cf5ac87a1d3a6954a460297 Mon Sep 17 00:00:00 2001 From: Philipp Basler Date: Fri, 10 Sep 2021 19:38:58 +0200 Subject: [PATCH] Changed scalar_normal_dist_op to class with user-defined moved constructor and assignment --- include/libcmaes/eigenmvn.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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); }