Remove usages of std::auto_ptr to get rid of warnings when building with

gcc 8.2+
This commit is contained in:
Tobias Widlund 2019-01-18 14:12:14 +01:00 committed by Lukas Dürrenberger
parent 353c846c87
commit bf92efe9a4

View File

@ -29,7 +29,7 @@
#include <SFML/Audio/ALCheck.hpp>
#include <SFML/Audio/Listener.hpp>
#include <SFML/System/Err.hpp>
#include <memory>
#include <vector>
namespace
@ -107,9 +107,13 @@ bool AudioDevice::isExtensionSupported(const std::string& extension)
// This device will not be used in this function and merely
// makes sure there is a valid OpenAL device for extension
// queries if none has been created yet.
std::auto_ptr<AudioDevice> device;
//
// Using an std::vector for this since auto_ptr is deprecated
// and we have no better STL facility for dynamically allocating
// a temporary instance with strong exception guarantee.
std::vector<AudioDevice> device;
if (!audioDevice)
device.reset(new AudioDevice);
device.resize(1);
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
@ -125,9 +129,13 @@ int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
// This device will not be used in this function and merely
// makes sure there is a valid OpenAL device for format
// queries if none has been created yet.
std::auto_ptr<AudioDevice> device;
//
// Using an std::vector for this since auto_ptr is deprecated
// and we have no better STL facility for dynamically allocating
// a temporary instance with strong exception guarantee.
std::vector<AudioDevice> device;
if (!audioDevice)
device.reset(new AudioDevice);
device.resize(1);
// Find the good format according to the number of channels
int format = 0;