From ba4511b03c7e3152e86b0c019ef00a1a303ac8d2 Mon Sep 17 00:00:00 2001 From: Jun An Date: Fri, 16 Mar 2018 07:38:19 +0800 Subject: [PATCH] Resolve wrong method updated error in RSModel. --- .../methods/range_search/rs_model_impl.hpp | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/mlpack/methods/range_search/rs_model_impl.hpp b/src/mlpack/methods/range_search/rs_model_impl.hpp index 5c55cac3ee..23879f278d 100644 --- a/src/mlpack/methods/range_search/rs_model_impl.hpp +++ b/src/mlpack/methods/range_search/rs_model_impl.hpp @@ -33,33 +33,33 @@ inline RSModel::RSModel(TreeTypes treeType, bool randomBasis) : // Nothing to do. } +// Copy constructor. +inline RSModel::RSModel(const RSModel& other) : + treeType(other.treeType), + leafSize(other.leafSize), + randomBasis(other.randomBasis), + q(other.q), + rSearch(other.rSearch) +{ + // Nothing to do. +} + // Move constructor. -inline RSModel::RSModel(RSModel other) : +inline RSModel::RSModel(RSModel&& other) : treeType(other.treeType), leafSize(other.leafSize), randomBasis(other.randomBasis), q(std::move(other.q)), rSearch(std::move(other.rSearch)) { - // Nothing to do. + // Reset other model. + other.treeType = TreeTypes::KD_TREE; + other.leafSize = 0; + other.randomBasis = false; + other.rSearch = decltype(other.rSearch)(); } -// Copy operator. -inline RSModel& RSModel::operator=(const RSModel& other) -{ - boost::apply_visitor(DeleteVisitor(), rSearch); - - treeType = other.treeType; - leafSize = other.leafSize; - randomBasis = other.randomBasis; - q = other.q; - rSearch = other.rSearch; - - return *this; -} - -// Move operator. -inline RSModel& RSModel::operator=(RSModel&& other) +inline RSModel& RSModel::operator=(RSModel other) { boost::apply_visitor(DeleteVisitor(), rSearch); @@ -69,12 +69,6 @@ inline RSModel& RSModel::operator=(RSModel&& other) q = std::move(other.q); rSearch = std::move(other.rSearch); - // Reset other model. - other.treeType = TreeTypes::KD_TREE; - other.leafSize = 0; - other.randomBasis = false; - other.rSearch = decltype(other.rSearch)(); - return *this; }