Add/remove necessary special member functions
Quite surprising to find the PFFFT C++ class had a non-deleted copy constructor. Add move/move assignment to make this a little nicer to work with.
This commit is contained in:
@@ -167,7 +167,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
Fft( int length, int stackThresholdLen = 4096 );
|
Fft( int length, int stackThresholdLen = 4096 );
|
||||||
|
|
||||||
|
Fft(const Fft&) = delete;
|
||||||
|
Fft& operator=(const Fft&) = delete;
|
||||||
|
Fft(Fft&& other) : setup(std::move(other.setup)), work(other.work),
|
||||||
|
length(other.length), stackThresholdLen(other.stackThresholdLen) {
|
||||||
|
other.work = nullptr;
|
||||||
|
other.length = 0;
|
||||||
|
};
|
||||||
|
Fft& operator=(Fft&& other) {
|
||||||
|
std::swap(setup, other.setup);
|
||||||
|
std::swap(work, other.work);
|
||||||
|
return *this;
|
||||||
|
};
|
||||||
/*
|
/*
|
||||||
* constructor or prepareLength() produced a valid FFT instance?
|
* constructor or prepareLength() produced a valid FFT instance?
|
||||||
* delivers false for invalid FFT sizes
|
* delivers false for invalid FFT sizes
|
||||||
@@ -388,7 +399,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
detail::Setup<T> setup;
|
detail::Setup<T> setup;
|
||||||
Scalar* work;
|
Scalar* work{};
|
||||||
int length;
|
int length;
|
||||||
int stackThresholdLen;
|
int stackThresholdLen;
|
||||||
};
|
};
|
||||||
@@ -439,6 +450,15 @@ public:
|
|||||||
Setup()
|
Setup()
|
||||||
: self(NULL)
|
: self(NULL)
|
||||||
{}
|
{}
|
||||||
|
Setup(const Setup&) = delete;
|
||||||
|
Setup& operator=(const Setup&) = delete;
|
||||||
|
Setup(Setup&& other) : self(other.self) {
|
||||||
|
other.self = nullptr;
|
||||||
|
}
|
||||||
|
Setup& operator=(Setup&& other) {
|
||||||
|
std::swap(self, other.self);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~Setup() { pffft_destroy_setup(self); }
|
~Setup() { pffft_destroy_setup(self); }
|
||||||
|
|
||||||
@@ -503,6 +523,15 @@ public:
|
|||||||
Setup()
|
Setup()
|
||||||
: self(NULL)
|
: self(NULL)
|
||||||
{}
|
{}
|
||||||
|
Setup(const Setup&) = delete;
|
||||||
|
Setup& operator=(const Setup&) = delete;
|
||||||
|
Setup(Setup&& other) : self(other.self) {
|
||||||
|
other.self = nullptr;
|
||||||
|
}
|
||||||
|
Setup& operator=(Setup&& other) {
|
||||||
|
std::swap(self, other.self);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~Setup() { pffft_destroy_setup(self); }
|
~Setup() { pffft_destroy_setup(self); }
|
||||||
|
|
||||||
@@ -563,6 +592,15 @@ public:
|
|||||||
Setup()
|
Setup()
|
||||||
: self(NULL)
|
: self(NULL)
|
||||||
{}
|
{}
|
||||||
|
Setup(const Setup&) = delete;
|
||||||
|
Setup& operator=(const Setup&) = delete;
|
||||||
|
Setup(Setup&& other) : self(other.self) {
|
||||||
|
other.self = nullptr;
|
||||||
|
}
|
||||||
|
Setup& operator=(Setup&& other) {
|
||||||
|
std::swap(self, other.self);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~Setup() { pffftd_destroy_setup(self); }
|
~Setup() { pffftd_destroy_setup(self); }
|
||||||
|
|
||||||
@@ -629,6 +667,15 @@ public:
|
|||||||
Setup()
|
Setup()
|
||||||
: self(NULL)
|
: self(NULL)
|
||||||
{}
|
{}
|
||||||
|
Setup(const Setup&) = delete;
|
||||||
|
Setup& operator=(const Setup&) = delete;
|
||||||
|
Setup(Setup&& other) : self(other.self) {
|
||||||
|
other.self = nullptr;
|
||||||
|
}
|
||||||
|
Setup& operator=(Setup&& other) {
|
||||||
|
std::swap(self, other.self);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~Setup() { pffftd_destroy_setup(self); }
|
~Setup() { pffftd_destroy_setup(self); }
|
||||||
|
|
||||||
@@ -687,8 +734,7 @@ public:
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Fft<T>::Fft(int length, int stackThresholdLen)
|
inline Fft<T>::Fft(int length, int stackThresholdLen)
|
||||||
: work(NULL)
|
: length(0)
|
||||||
, length(0)
|
|
||||||
, stackThresholdLen(stackThresholdLen)
|
, stackThresholdLen(stackThresholdLen)
|
||||||
{
|
{
|
||||||
#if (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900))
|
#if (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900))
|
||||||
|
|||||||
Reference in New Issue
Block a user