Reputation: 249
I have create the following class which contains an owned array of convolvers, and I have tried to create a getter function to access the convovlers within another class:
class ImpulseCreator
{
public:
ImpulseCreator();
~ImpulseCreator();
OwnedArray<fftconvolver::FFTConvolver> getConvolver();
private:
//convolver
AudioSampleBuffer impulseBuffer1;
AudioSampleBuffer impulseBuffer2;
AudioSampleBuffer finalImpulseBuffer;
OwnedArray<fftconvolver::FFTConvolver> preConvolvers;
OwnedArray<fftconvolver::FFTConvolver> convolvers;
};
Then in the .cpp file I have the following code:
OwnedArray<fftconvolver::FFTConvolver> ImpulseCreator::getConvolver()
{
return convolvers;
}
On the "return convolvers;" line, i am receiving an error which says:
Call to deleted constructor of OwnedArray<fftconvolver::FFTConvolver>
Any ideas?
Upvotes: 1
Views: 111
Reputation: 42899
You're returning by copy, try returning by reference:
OwnedArray<fftconvolver::FFTConvolver>&
ImpulseCreator::getConvolver() {
return convolvers;
}
OwnedArray<fftconvolver::FFTConvolver> const&
ImpulseCreator::getConvolver() const {
return convolvers;
}
The compiler is telling you that the OwnedArray
destructor is declared deleted. Guessing from the name the OwnedArray
is owned by someone else, thus you're not allowed to destruct its objects in a non friendly context.
Upvotes: 1
Reputation: 117866
You should change the signature of your function to
OwnedArray<fftconvolver::FFTConvolver> const& getConvolver() const;
so you are returning a reference to the array. As written, it will return a copy of the array, which the compiler seems to be telling you that the copy constructor is deleted.
If you need to be able to modify the contents of the array you could also return a non-const reference
OwnedArray<fftconvolver::FFTConvolver>& getConvolver();
Upvotes: 1