Prevent using a temporary sf::SoundBuffer with sf::Sound

This commit is contained in:
Chris Thrasher 2023-01-05 17:58:49 -07:00
parent 2d0c923a53
commit 098f6927d2
2 changed files with 13 additions and 0 deletions

View File

@ -60,6 +60,12 @@ public:
////////////////////////////////////////////////////////////
explicit Sound(const SoundBuffer& buffer);
////////////////////////////////////////////////////////////
/// \brief Disallow construction from a temporary sound buffer
///
////////////////////////////////////////////////////////////
explicit Sound(SoundBuffer&& buffer) = delete;
////////////////////////////////////////////////////////////
/// \brief Copy constructor
///
@ -125,6 +131,12 @@ public:
////////////////////////////////////////////////////////////
void setBuffer(const SoundBuffer& buffer);
////////////////////////////////////////////////////////////
/// \brief Disallow setting from a temporary sound buffer
///
////////////////////////////////////////////////////////////
void setBuffer(SoundBuffer&& buffer) = delete;
////////////////////////////////////////////////////////////
/// \brief Set whether or not the sound should loop after reaching the end
///

View File

@ -2,6 +2,7 @@
#include <type_traits>
static_assert(!std::is_constructible_v<sf::Sound, sf::SoundBuffer&&>);
static_assert(std::is_copy_constructible_v<sf::Sound>);
static_assert(std::is_copy_assignable_v<sf::Sound>);
static_assert(std::is_move_constructible_v<sf::Sound>);