From bf92efe9a4035fee0258386173d53556aa196e49 Mon Sep 17 00:00:00 2001 From: Tobias Widlund Date: Fri, 18 Jan 2019 14:12:14 +0100 Subject: [PATCH] Remove usages of std::auto_ptr to get rid of warnings when building with gcc 8.2+ --- src/SFML/Audio/AudioDevice.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp index ab6cb90d..e4ebc4b9 100644 --- a/src/SFML/Audio/AudioDevice.cpp +++ b/src/SFML/Audio/AudioDevice.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include 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 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 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 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 device; if (!audioDevice) - device.reset(new AudioDevice); + device.resize(1); // Find the good format according to the number of channels int format = 0;