I am sure this is more of a C++11/C++14 question then a JUCE question.
juce::AudioDeviceManager *DeviceManager;
DeviceManager=new juce::AudioDeviceManager()
juce::AudioDeviceManager::AudioDeviceSetup *DeviceSetup;
DeviceSetup=new juce::AudioDeviceManager::AudioDeviceSetup()
I now want to make a copy of the contents of the currentSetup which is hanging off of
class JUCE_API AudioDeviceManager : public ChangeBroadcaster
{
AudioDeviceSetup currentSetup;
}
In order to get access to it, one should clearly utilize:
AudioDeviceManager::AudioDeviceSetup AudioDeviceManager::getAudioDeviceSetup() const
{
return currentSetup;
}
Being an old school C/C++ programmer, I am quite confused by this.
currentSetup is a struct.
AudioDeviceManager::AudioDeviceSetup AudioDeviceManager::getAudioDeviceSetup()
is returning the struct (which I have never seen before), not a pointer to the struct.
I am pretty sure this must be some sort of new C++11/C++14 type functionality that can only be understood by you youngsters!
To be honest I do not understand it!
memcpy(DeviceSetup,&(this->DeviceManager->getAudioDeviceSetup)(),sizeof(juce::AudioDeviceManager::AudioDeviceSetup));
seems to âworkâ (meaning it does not crash), but still seems wrong to me. In addition the above statement produces a
âwarning C4238: nonstandard extension used: class rvalue used as lvalueâ (Visual Studio 2017)
I understand that I am taking an address of an rvalue, which is in fact bad.
I do understand that I could pick of each member of currentSetup and assign the value to my
DeviceSetup. I.e.:
DeviceSetup->outputDeviceName=(DeviceManager->getAudioDeviceSetup)().outputDeviceName;
for each member, but this does not seem wise as I am sure that at some point members could be added to the AudioDeviceSetup class / struct in future releases and I would never be aware of it.
So, again, I really do not understand what is actually being returned by
AudioDeviceManager::AudioDeviceSetup AudioDeviceManager::getAudioDeviceSetup()
I am hoping this does not sound like psychotic babble?
Thanks in advance for any direction.
