diff --git a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h index bc3638282f..0d17f25cfb 100644 --- a/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h +++ b/modules/juce_audio_basics/buffers/juce_AudioSampleBuffer.h @@ -190,6 +190,39 @@ public: */ ~AudioBuffer() noexcept {} + #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS + /** Move constructor */ + AudioBuffer (AudioBuffer&& other) noexcept + : numChannels (other.numChannels), + size (other.size), + allocatedBytes (other.allocatedBytes), + channels (other.channels), + allocatedData (static_cast&&> (other.allocatedData)), + isClear (other.isClear) + { + memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); + other.numChannels = 0; + other.size = 0; + other.allocatedBytes = 0; + } + + /** Move assignment */ + AudioBuffer& operator= (AudioBuffer&& other) noexcept + { + numChannels = other.numChannels; + size = other.size; + allocatedBytes = other.allocatedBytes; + channels = other.channels; + allocatedData = static_cast&&> (other.allocatedData); + isClear = other.isClear; + memcpy (preallocatedChannelSpace, other.preallocatedChannelSpace, sizeof (preallocatedChannelSpace)); + other.numChannels = 0; + other.size = 0; + other.allocatedBytes = 0; + return *this; + } + #endif + //============================================================================== /** Returns the number of channels of audio data that this buffer contains. @see getSampleData