From d02d3590fd0709332d8e62a22e5b446ea2f62908 Mon Sep 17 00:00:00 2001 From: Vittorio Romeo Date: Thu, 9 Dec 2021 19:04:50 +0000 Subject: [PATCH] Use 'std::optional' instead of 'std::vector' for temporary 'AudioDevice' --- src/SFML/Audio/AudioDevice.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/SFML/Audio/AudioDevice.cpp b/src/SFML/Audio/AudioDevice.cpp index 87315c5c2..8c8ba19ea 100644 --- a/src/SFML/Audio/AudioDevice.cpp +++ b/src/SFML/Audio/AudioDevice.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace @@ -107,13 +107,9 @@ 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. - // - // 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; + std::optional device; if (!audioDevice) - device.resize(1); + device.emplace(); if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC")) return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE; @@ -129,13 +125,9 @@ 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. - // - // 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; + std::optional device; if (!audioDevice) - device.resize(1); + device.emplace(); // Find the good format according to the number of channels int format = 0;