mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-31 03:00:05 +00:00
Added move semantics to AudioBuffer
This commit is contained in:
parent
aae0b15916
commit
5eeaf5a2b5
1 changed files with 33 additions and 0 deletions
|
|
@ -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<HeapBlock<char, true>&&> (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<HeapBlock<char, true>&&> (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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue