add move assignment operator and fix static code check
This commit is contained in:
@@ -86,6 +86,9 @@ class HollowBallBound
|
||||
//! Move constructor: take possession of another bound.
|
||||
HollowBallBound(HollowBallBound&& other);
|
||||
|
||||
//! Move assignment operator.
|
||||
HollowBallBound& operator=(HollowBallBound&& other);
|
||||
|
||||
//! Destructor to release allocated memory.
|
||||
~HollowBallBound();
|
||||
|
||||
|
||||
@@ -80,15 +80,17 @@ template<typename TMetricType, typename ElemType>
|
||||
HollowBallBound<TMetricType, ElemType>& HollowBallBound<TMetricType, ElemType>::
|
||||
operator=(const HollowBallBound& other)
|
||||
{
|
||||
if (ownsMetric)
|
||||
delete metric;
|
||||
|
||||
radii = other.radii;
|
||||
center = other.center;
|
||||
hollowCenter = other.hollowCenter;
|
||||
metric = other.metric;
|
||||
ownsMetric = false;
|
||||
if (this != &other)
|
||||
{
|
||||
if (ownsMetric)
|
||||
delete metric;
|
||||
|
||||
radii = other.radii;
|
||||
center = other.center;
|
||||
hollowCenter = other.hollowCenter;
|
||||
metric = other.metric;
|
||||
ownsMetric = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -111,6 +113,29 @@ HollowBallBound<TMetricType, ElemType>::HollowBallBound(
|
||||
other.ownsMetric = false;
|
||||
}
|
||||
|
||||
//! Move assignment operator.
|
||||
template<typename TMetricType, typename ElemType>
|
||||
HollowBallBound<TMetricType, ElemType>& HollowBallBound<TMetricType, ElemType>::
|
||||
operator=(HollowBallBound&& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
radii = other.radii;
|
||||
center = std::move(other.center);
|
||||
hollowCenter = std::move(other.hollowCenter);
|
||||
metric = other.metric;
|
||||
ownsMetric = other.ownsMetric;
|
||||
|
||||
other.radii.Hi() = 0.0;
|
||||
other.radii.Lo() = 0.0;
|
||||
other.center = arma::Col<ElemType>();
|
||||
other.hollowCenter = arma::Col<ElemType>();
|
||||
other.metric = nullptr;
|
||||
other.ownsMetric = false;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
//! Destructor to release allocated memory.
|
||||
template<typename TMetricType, typename ElemType>
|
||||
HollowBallBound<TMetricType, ElemType>::~HollowBallBound()
|
||||
|
||||
Reference in New Issue
Block a user