diff --git a/.clang-tidy b/.clang-tidy index 40473e05f..409d22a0d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -2,6 +2,8 @@ Checks: > -*, clang-analyzer-*, modernize-concat-nested-namespaces, + modernize-use-equals-default, + modernize-use-equals-delete, modernize-use-nullptr, readability-identifier-naming, -clang-analyzer-core.NonNullParamChecker, diff --git a/examples/shader/Effect.hpp b/examples/shader/Effect.hpp index 2eaf6dfa1..e82f4e1cf 100644 --- a/examples/shader/Effect.hpp +++ b/examples/shader/Effect.hpp @@ -15,9 +15,7 @@ class Effect : public sf::Drawable { public: - ~Effect() override - { - } + ~Effect() override = default; static void setFont(const sf::Font& font) { diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index ee94afc48..af67b2c44 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -124,6 +124,7 @@ Font::Font() = default; //////////////////////////////////////////////////////////// +// NOLINTNEXTLINE(modernize-use-equals-default) Font::Font(const Font& copy) : m_fontHandles(copy.m_fontHandles), m_isSmooth(copy.m_isSmooth), diff --git a/src/SFML/Graphics/ImageLoader.hpp b/src/SFML/Graphics/ImageLoader.hpp index 78ea23709..6f1c67cb3 100644 --- a/src/SFML/Graphics/ImageLoader.hpp +++ b/src/SFML/Graphics/ImageLoader.hpp @@ -49,6 +49,18 @@ namespace priv class ImageLoader { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + ImageLoader(const ImageLoader&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + ImageLoader& operator=(const ImageLoader&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the unique instance of the class /// @@ -128,18 +140,6 @@ private: /// //////////////////////////////////////////////////////////// ImageLoader(); - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - ImageLoader(const ImageLoader&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - ImageLoader& operator=(const ImageLoader&) = delete; }; } // namespace priv diff --git a/src/SFML/System/String.cpp b/src/SFML/System/String.cpp index 280332d3f..0e44ebc65 100644 --- a/src/SFML/System/String.cpp +++ b/src/SFML/System/String.cpp @@ -120,9 +120,7 @@ String::String(const std::basic_string& utf32String) : m_string(u //////////////////////////////////////////////////////////// -String::String(const String& copy) : m_string(copy.m_string) -{ -} +String::String(const String& copy) = default; //////////////////////////////////////////////////////////// @@ -211,11 +209,7 @@ std::basic_string String::toUtf32() const //////////////////////////////////////////////////////////// -String& String::operator=(const String& right) -{ - m_string = right.m_string; - return *this; -} +String& String::operator=(const String& right) = default; //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/JoystickManager.hpp b/src/SFML/Window/JoystickManager.hpp index 39b72e20b..12278b009 100644 --- a/src/SFML/Window/JoystickManager.hpp +++ b/src/SFML/Window/JoystickManager.hpp @@ -40,6 +40,18 @@ namespace sf::priv class JoystickManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + JoystickManager(const JoystickManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + JoystickManager& operator=(const JoystickManager&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the global unique instance of the manager /// @@ -97,18 +109,6 @@ private: //////////////////////////////////////////////////////////// ~JoystickManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - JoystickManager(const JoystickManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - JoystickManager& operator=(const JoystickManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Joystick information and state /// diff --git a/src/SFML/Window/OSX/HIDInputManager.hpp b/src/SFML/Window/OSX/HIDInputManager.hpp index 6803699c3..3ee15d078 100644 --- a/src/SFML/Window/OSX/HIDInputManager.hpp +++ b/src/SFML/Window/OSX/HIDInputManager.hpp @@ -51,6 +51,18 @@ using IOHIDElements = std::vector; class HIDInputManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + HIDInputManager(const HIDInputManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + HIDInputManager& operator=(const HIDInputManager&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the unique instance of the class /// @@ -127,18 +139,6 @@ private: //////////////////////////////////////////////////////////// ~HIDInputManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - HIDInputManager(const HIDInputManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - HIDInputManager& operator=(const HIDInputManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Initialize the keyboard part of this class /// diff --git a/src/SFML/Window/OSX/HIDJoystickManager.hpp b/src/SFML/Window/OSX/HIDJoystickManager.hpp index 674a9a0e0..29d5425a9 100644 --- a/src/SFML/Window/OSX/HIDJoystickManager.hpp +++ b/src/SFML/Window/OSX/HIDJoystickManager.hpp @@ -43,6 +43,19 @@ namespace sf::priv class HIDJoystickManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + HIDJoystickManager(const HIDJoystickManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + HIDJoystickManager& operator=(const HIDJoystickManager&) = delete; + + //////////////////////////////////////////////////////////// /// \brief Get the unique instance of the class /// @@ -81,18 +94,6 @@ private: //////////////////////////////////////////////////////////// ~HIDJoystickManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - HIDJoystickManager(const HIDJoystickManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - HIDJoystickManager& operator=(const HIDJoystickManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Make sure all event have been processed in the run loop /// diff --git a/src/SFML/Window/SensorManager.hpp b/src/SFML/Window/SensorManager.hpp index e62f17826..8e7c3143d 100644 --- a/src/SFML/Window/SensorManager.hpp +++ b/src/SFML/Window/SensorManager.hpp @@ -40,6 +40,18 @@ namespace sf::priv class SensorManager { public: + //////////////////////////////////////////////////////////// + /// \brief Deleted copy constructor + /// + //////////////////////////////////////////////////////////// + SensorManager(const SensorManager&) = delete; + + //////////////////////////////////////////////////////////// + /// \brief Deleted copy assignment + /// + //////////////////////////////////////////////////////////// + SensorManager& operator=(const SensorManager&) = delete; + //////////////////////////////////////////////////////////// /// \brief Get the global unique instance of the manager /// @@ -106,18 +118,6 @@ private: //////////////////////////////////////////////////////////// ~SensorManager(); - //////////////////////////////////////////////////////////// - /// \brief Deleted copy constructor - /// - //////////////////////////////////////////////////////////// - SensorManager(const SensorManager&) = delete; - - //////////////////////////////////////////////////////////// - /// \brief Deleted copy assignment - /// - //////////////////////////////////////////////////////////// - SensorManager& operator=(const SensorManager&) = delete; - //////////////////////////////////////////////////////////// /// \brief Sensor information and state ///