mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Use explicit constructors when implicit construction isn't wanted
This commit is contained in:
parent
816855d13f
commit
ecb945b341
@ -40,7 +40,7 @@ public:
|
|||||||
// The operator()s can also have void return type if there is nothing to return.
|
// The operator()s can also have void return type if there is nothing to return.
|
||||||
struct Visitor
|
struct Visitor
|
||||||
{
|
{
|
||||||
Visitor(Application& app) : application(app)
|
explicit Visitor(Application& app) : application(app)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Effect(std::string name) : m_name(std::move(name))
|
explicit Effect(std::string name) : m_name(std::move(name))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,7 +665,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Processing(std::string name) :
|
explicit Processing(std::string name) :
|
||||||
Effect(std::move(name)),
|
Effect(std::move(name)),
|
||||||
m_enabledText(getFont(), "Processing: Enabled"),
|
m_enabledText(getFont(), "Processing: Enabled"),
|
||||||
m_instructions(getFont(), "Press Space to enable/disable processing")
|
m_instructions(getFont(), "Press Space to enable/disable processing")
|
||||||
@ -990,7 +990,7 @@ private:
|
|||||||
class FIRFilter
|
class FIRFilter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FIRFilter(std::vector<float> taps) : m_taps(std::move(taps))
|
explicit FIRFilter(std::vector<float> taps) : m_taps(std::move(taps))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public:
|
|||||||
/// \throws `sf::Exception` if opening the file was unsuccessful
|
/// \throws `sf::Exception` if opening the file was unsuccessful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
InputSoundFile(const std::filesystem::path& filename);
|
explicit InputSoundFile(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct a sound file in memory for reading
|
/// \brief Construct a sound file in memory for reading
|
||||||
@ -103,7 +103,7 @@ public:
|
|||||||
/// \throws `sf::Exception` if opening the file was unsuccessful
|
/// \throws `sf::Exception` if opening the file was unsuccessful
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
InputSoundFile(InputStream& stream);
|
explicit InputSoundFile(InputStream& stream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Open a sound file from the disk for reading
|
/// \brief Open a sound file from the disk for reading
|
||||||
|
@ -93,7 +93,7 @@ public:
|
|||||||
/// \see `openFromMemory`, `openFromStream`
|
/// \see `openFromMemory`, `openFromStream`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Music(const std::filesystem::path& filename);
|
explicit Music(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct a music from an audio file in memory
|
/// \brief Construct a music from an audio file in memory
|
||||||
@ -137,7 +137,7 @@ public:
|
|||||||
/// \see `openFromFile`, `openFromMemory`
|
/// \see `openFromFile`, `openFromMemory`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Music(InputStream& stream);
|
explicit Music(InputStream& stream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Destructor
|
/// \brief Destructor
|
||||||
|
@ -59,7 +59,7 @@ public:
|
|||||||
/// \brief Disallow construction from a temporary sound buffer
|
/// \brief Disallow construction from a temporary sound buffer
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
explicit Sound(const SoundBuffer&& buffer) = delete;
|
Sound(const SoundBuffer&& buffer) = delete;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Copy constructor
|
/// \brief Copy constructor
|
||||||
|
@ -84,7 +84,7 @@ public:
|
|||||||
/// \see `loadFromMemory`, `loadFromStream`, `loadFromSamples`, `saveToFile`
|
/// \see `loadFromMemory`, `loadFromStream`, `loadFromSamples`, `saveToFile`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SoundBuffer(const std::filesystem::path& filename);
|
explicit SoundBuffer(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct the sound buffer from a file in memory
|
/// \brief Construct the sound buffer from a file in memory
|
||||||
@ -115,7 +115,7 @@ public:
|
|||||||
/// \see `loadFromFile`, `loadFromMemory`, `loadFromSamples`
|
/// \see `loadFromFile`, `loadFromMemory`, `loadFromSamples`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
SoundBuffer(InputStream& stream);
|
explicit SoundBuffer(InputStream& stream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct the sound buffer from an array of audio samples
|
/// \brief Construct the sound buffer from an array of audio samples
|
||||||
|
@ -100,7 +100,7 @@ public:
|
|||||||
/// \see `openFromFile`, `openFromMemory`, `openFromStream`
|
/// \see `openFromFile`, `openFromMemory`, `openFromStream`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Font(const std::filesystem::path& filename);
|
explicit Font(const std::filesystem::path& filename);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Construct the font from a file in memory
|
/// \brief Construct the font from a file in memory
|
||||||
@ -143,7 +143,7 @@ public:
|
|||||||
/// \see `openFromFile`, `openFromMemory`, `openFromStream`
|
/// \see `openFromFile`, `openFromMemory`, `openFromStream`
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Font(InputStream& stream);
|
explicit Font(InputStream& stream);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Open the font from a file
|
/// \brief Open the font from a file
|
||||||
|
@ -139,7 +139,7 @@ protected:
|
|||||||
/// \param type Type of the socket (TCP or UDP)
|
/// \param type Type of the socket (TCP or UDP)
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Socket(Type type);
|
explicit Socket(Type type);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the internal handle of the socket
|
/// \brief Return the internal handle of the socket
|
||||||
|
@ -45,7 +45,7 @@ namespace sf
|
|||||||
{
|
{
|
||||||
struct SoundRecorder::Impl
|
struct SoundRecorder::Impl
|
||||||
{
|
{
|
||||||
Impl(SoundRecorder* ownerPtr) : owner(ownerPtr)
|
explicit Impl(SoundRecorder* ownerPtr) : owner(ownerPtr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace sf
|
|||||||
{
|
{
|
||||||
struct SoundStream::Impl : priv::MiniaudioUtils::SoundBase
|
struct SoundStream::Impl : priv::MiniaudioUtils::SoundBase
|
||||||
{
|
{
|
||||||
Impl(SoundStream* ownerPtr) :
|
explicit Impl(SoundStream* ownerPtr) :
|
||||||
SoundBase(vtable, [](void* ptr) { static_cast<Impl*>(ptr)->initialize(); }),
|
SoundBase(vtable, [](void* ptr) { static_cast<Impl*>(ptr)->initialize(); }),
|
||||||
owner(ownerPtr)
|
owner(ownerPtr)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ class Ftp::DataChannel
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
DataChannel(Ftp& owner);
|
explicit DataChannel(Ftp& owner);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Deleted copy constructor
|
/// \brief Deleted copy constructor
|
||||||
|
@ -84,7 +84,7 @@ int handleXError(::Display*, XErrorEvent*)
|
|||||||
class GlxErrorHandler
|
class GlxErrorHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GlxErrorHandler(::Display* display) : m_display(display)
|
explicit GlxErrorHandler(::Display* display) : m_display(display)
|
||||||
{
|
{
|
||||||
glxErrorOccurred = false;
|
glxErrorOccurred = false;
|
||||||
m_previousHandler = XSetErrorHandler(handleXError);
|
m_previousHandler = XSetErrorHandler(handleXError);
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
/// \param shared Context to share the new one with (can be a null pointer)
|
/// \param shared Context to share the new one with (can be a null pointer)
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
GlxContext(GlxContext* shared);
|
explicit GlxContext(GlxContext* shared);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create a new context attached to a window
|
/// \brief Create a new context attached to a window
|
||||||
|
@ -53,7 +53,7 @@ public:
|
|||||||
/// \param handle Platform-specific handle of the control
|
/// \param handle Platform-specific handle of the control
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplX11(WindowHandle handle);
|
explicit WindowImplX11(WindowHandle handle);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Create the window implementation
|
/// \brief Create the window implementation
|
||||||
|
@ -28,7 +28,7 @@ class TemporaryFile
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Create a temporary file with a randomly generated path, containing 'contents'.
|
// Create a temporary file with a randomly generated path, containing 'contents'.
|
||||||
TemporaryFile(const std::string& contents) : m_path(getTemporaryFilePath())
|
explicit TemporaryFile(const std::string& contents) : m_path(getTemporaryFilePath())
|
||||||
{
|
{
|
||||||
std::ofstream ofs(m_path);
|
std::ofstream ofs(m_path);
|
||||||
assert(ofs && "Stream encountered an error");
|
assert(ofs && "Stream encountered an error");
|
||||||
|
Loading…
Reference in New Issue
Block a user