diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e5a4084..d36a220c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,15 @@ if (NOT DEFINED CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type") endif () -set(CMAKE_CXX_FLAGS "-Wall -Wextra") -set(CMAKE_CXX_FLAGS_DEBUG "-g") -set(CMAKE_CXX_FLAGS_RELEASE "-O3") +if(MSVC) + set(CMAKE_CXX_FLAGS "/W4") + set(CMAKE_CXX_FLAGS_DEBUG "/Zi /Od") + set(CMAKE_CXX_FLAGS_RELEASE "/O2") +else() + set(CMAKE_CXX_FLAGS "-Wall -Wextra") + set(CMAKE_CXX_FLAGS_DEBUG "-g") + set(CMAKE_CXX_FLAGS_RELEASE "-O3") +endif() list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) diff --git a/include/libcmaes/eigenmvn.h b/include/libcmaes/eigenmvn.h index fb8b11d4..85b5f014 100644 --- a/include/libcmaes/eigenmvn.h +++ b/include/libcmaes/eigenmvn.h @@ -58,18 +58,28 @@ namespace Eigen { 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) - { + scalar_normal_dist_op() : norm(Scalar(0), Scalar(1)) {} + + scalar_normal_dist_op(const scalar_normal_dist_op& other) + : norm(other.norm) { + } + + scalar_normal_dist_op& operator=(const scalar_normal_dist_op& other) { if (this != &other) { - swap(other); + norm = other.norm; } return *this; } - - scalar_normal_dist_op(scalar_normal_dist_op &&other) { - *this = std::move(other); + + scalar_normal_dist_op(scalar_normal_dist_op&& other) noexcept + : norm(std::move(other.norm)) { + } + + scalar_normal_dist_op& operator=(scalar_normal_dist_op&& other) noexcept { + if (this != &other) { + norm = std::move(other.norm); + } + return *this; } template