I am using OpenAL for playing audio in an SDL2 game, and making some classes to make playing sounds easier. I have a class 'SndBuffer':
class SndBuffer
{
public:
/* implementation functions */
private:
// the only member of this class (this class does not have any virtual functions either). ALuint is a typedef for unsigned int.
ALuint m_bufferId;
};
And another class 'SndSource' which contains an std::vector of SndBuffer's.
class SndSource
{
public:
/* other implementation functions */
ALuint* getBufferIds();
private:
ALuint m_sourceId;
bool m_sourceLoaded = false;
std::vector<SndBuffer> m_buffers;
};
The definition of SndSource::getBufferIds is
ALuint* SndSource::getBufferIds()
{
return reinterpret_cast<ALuint*>(m_buffers.data());
}
So far, the audio playback works as normal and no errors through OpenAL's alGetError(), however, is it considered undefined behaviour to cast the vector's data to ALuint*?