Make all single-argument constructors explicit

This commit is contained in:
Davide Pesavento 2025-07-20 18:01:22 -04:00
parent 9ab4e4d70c
commit 7b01acdb81
31 changed files with 51 additions and 52 deletions

View File

@ -16,7 +16,7 @@ class BinarySpanReader
{ {
public: public:
BinarySpanReader(); BinarySpanReader();
BinarySpanReader(std::span<const u8> buf); explicit BinarySpanReader(std::span<const u8> buf);
BinarySpanReader(const BinarySpanReader&) = delete; BinarySpanReader(const BinarySpanReader&) = delete;
BinarySpanReader& operator=(const BinarySpanReader&) = delete; BinarySpanReader& operator=(const BinarySpanReader&) = delete;
@ -146,7 +146,7 @@ class BinarySpanWriter
{ {
public: public:
BinarySpanWriter(); BinarySpanWriter();
BinarySpanWriter(std::span<u8> buf); explicit BinarySpanWriter(std::span<u8> buf);
BinarySpanWriter(const BinarySpanWriter&) = delete; BinarySpanWriter(const BinarySpanWriter&) = delete;
BinarySpanWriter& operator=(const BinarySpanWriter&) = delete; BinarySpanWriter& operator=(const BinarySpanWriter&) = delete;
@ -217,8 +217,8 @@ class BinaryFileReader
{ {
public: public:
BinaryFileReader(); BinaryFileReader();
BinaryFileReader(std::FILE* fp); explicit BinaryFileReader(std::FILE* fp);
BinaryFileReader(const BinaryFileReader&) = delete; BinaryFileReader(const BinaryFileReader&) = delete;
BinaryFileReader& operator=(const BinaryFileReader&) = delete; BinaryFileReader& operator=(const BinaryFileReader&) = delete;
@ -308,8 +308,8 @@ class BinaryFileWriter
{ {
public: public:
BinaryFileWriter(); BinaryFileWriter();
BinaryFileWriter(std::FILE* fp); explicit BinaryFileWriter(std::FILE* fp);
BinaryFileWriter(const BinaryFileWriter&) = delete; BinaryFileWriter(const BinaryFileWriter&) = delete;
BinaryFileWriter& operator=(const BinaryFileWriter&) = delete; BinaryFileWriter& operator=(const BinaryFileWriter&) = delete;

View File

@ -19,7 +19,7 @@ public:
DynamicLibrary(); DynamicLibrary();
/// Automatically loads the specified library. Call IsOpen() to check validity before use. /// Automatically loads the specified library. Call IsOpen() to check validity before use.
DynamicLibrary(const char* filename); explicit DynamicLibrary(const char* filename);
/// Move constructor, transfers ownership. /// Move constructor, transfers ownership.
DynamicLibrary(DynamicLibrary&& move); DynamicLibrary(DynamicLibrary&& move);

View File

@ -165,8 +165,8 @@ class POSIXLock
{ {
public: public:
POSIXLock(); POSIXLock();
POSIXLock(int fd, bool block = true, Error* error = nullptr); explicit POSIXLock(int fd, bool block = true, Error* error = nullptr);
POSIXLock(std::FILE* fp, bool block = true, Error* error = nullptr); explicit POSIXLock(std::FILE* fp, bool block = true, Error* error = nullptr);
POSIXLock(POSIXLock&& move); POSIXLock(POSIXLock&& move);
POSIXLock(const POSIXLock&) = delete; POSIXLock(const POSIXLock&) = delete;
~POSIXLock(); ~POSIXLock();

View File

@ -167,7 +167,7 @@ public:
using this_type = DynamicHeapArray<T, alignment>; using this_type = DynamicHeapArray<T, alignment>;
DynamicHeapArray() : m_data(nullptr), m_size(0) {} DynamicHeapArray() : m_data(nullptr), m_size(0) {}
DynamicHeapArray(size_t size) { internal_resize(size, nullptr, 0); } explicit DynamicHeapArray(size_t size) { internal_resize(size, nullptr, 0); }
DynamicHeapArray(const T* begin, const T* end) DynamicHeapArray(const T* begin, const T* end)
{ {
const size_t size = reinterpret_cast<const char*>(end) - reinterpret_cast<const char*>(begin); const size_t size = reinterpret_cast<const char*>(end) - reinterpret_cast<const char*>(begin);
@ -195,7 +195,7 @@ public:
m_size = 0; m_size = 0;
} }
} }
DynamicHeapArray(const std::span<const T> data) explicit DynamicHeapArray(const std::span<const T> data)
{ {
if (!data.empty()) if (!data.empty())
{ {

View File

@ -8,7 +8,7 @@
class PerfScope class PerfScope
{ {
public: public:
constexpr PerfScope(const char* prefix) : m_prefix(prefix) {} constexpr explicit PerfScope(const char* prefix) : m_prefix(prefix) {}
bool HasPrefix() const { return (m_prefix && m_prefix[0]); } bool HasPrefix() const { return (m_prefix && m_prefix[0]); }
void Register(const void* ptr, size_t size, const char* symbol); void Register(const void* ptr, size_t size, const char* symbol);

View File

@ -60,7 +60,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
AnalogController(u32 index); explicit AnalogController(u32 index);
~AnalogController() override; ~AnalogController() override;
static std::unique_ptr<AnalogController> Create(u32 index); static std::unique_ptr<AnalogController> Create(u32 index);

View File

@ -32,7 +32,7 @@ namespace {
class CheatFileReader class CheatFileReader
{ {
public: public:
CheatFileReader(const std::string_view contents) : m_contents(contents) {} explicit CheatFileReader(const std::string_view contents) : m_contents(contents) {}
ALWAYS_INLINE size_t GetCurrentOffset() const { return m_current_offset; } ALWAYS_INLINE size_t GetCurrentOffset() const { return m_current_offset; }
ALWAYS_INLINE size_t GetCurrentLineOffset() const { return m_current_line_offset; } ALWAYS_INLINE size_t GetCurrentLineOffset() const { return m_current_line_offset; }
@ -178,7 +178,7 @@ public:
}; };
public: public:
CheatCode(Metadata metadata); explicit CheatCode(Metadata metadata);
virtual ~CheatCode(); virtual ~CheatCode();
ALWAYS_INLINE const Metadata& GetMetadata() const { return m_metadata; } ALWAYS_INLINE const Metadata& GetMetadata() const { return m_metadata; }
@ -2034,7 +2034,7 @@ namespace {
class GamesharkCheatCode final : public CheatCode class GamesharkCheatCode final : public CheatCode
{ {
public: public:
GamesharkCheatCode(Metadata metadata); explicit GamesharkCheatCode(Metadata metadata);
~GamesharkCheatCode() override; ~GamesharkCheatCode() override;
static std::unique_ptr<GamesharkCheatCode> Parse(Metadata metadata, const std::string_view data, Error* error); static std::unique_ptr<GamesharkCheatCode> Parse(Metadata metadata, const std::string_view data, Error* error);

View File

@ -53,7 +53,7 @@ public:
static constexpr float DEFAULT_STICK_SENSITIVITY = 1.33f; static constexpr float DEFAULT_STICK_SENSITIVITY = 1.33f;
static constexpr float DEFAULT_BUTTON_DEADZONE = 0.25f; static constexpr float DEFAULT_BUTTON_DEADZONE = 0.25f;
Controller(u32 index); explicit Controller(u32 index);
virtual ~Controller(); virtual ~Controller();
/// Returns the type of controller. /// Returns the type of controller.

View File

@ -57,7 +57,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
DDGoController(u32 index); explicit DDGoController(u32 index);
~DDGoController() override; ~DDGoController() override;
static std::unique_ptr<DDGoController> Create(u32 index); static std::unique_ptr<DDGoController> Create(u32 index);

View File

@ -84,7 +84,7 @@ void SetStandardSelectionFooterText(bool back_instead_of_cancel);
class BackgroundProgressCallback final : public ProgressCallback class BackgroundProgressCallback final : public ProgressCallback
{ {
public: public:
BackgroundProgressCallback(std::string name); explicit BackgroundProgressCallback(std::string name);
~BackgroundProgressCallback() override; ~BackgroundProgressCallback() override;
void SetStatusText(const std::string_view text) override; void SetStatusText(const std::string_view text) override;

View File

@ -17,7 +17,7 @@
class GPU_SW final : public GPUBackend class GPU_SW final : public GPUBackend
{ {
public: public:
GPU_SW(GPUPresenter& presenter); explicit GPU_SW(GPUPresenter& presenter);
~GPU_SW() override; ~GPU_SW() override;
bool Initialize(bool upload_vram, Error* error) override; bool Initialize(bool upload_vram, Error* error) override;

View File

@ -27,7 +27,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
GunCon(u32 index); explicit GunCon(u32 index);
~GunCon() override; ~GunCon() override;
static std::unique_ptr<GunCon> Create(u32 index); static std::unique_ptr<GunCon> Create(u32 index);

View File

@ -43,7 +43,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
JogCon(u32 index); explicit JogCon(u32 index);
~JogCon() override; ~JogCon() override;
static std::unique_ptr<JogCon> Create(u32 index); static std::unique_ptr<JogCon> Create(u32 index);

View File

@ -81,7 +81,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
NeGcon(u32 index); explicit NeGcon(u32 index);
~NeGcon() override; ~NeGcon() override;
static std::unique_ptr<NeGcon> Create(u32 index); static std::unique_ptr<NeGcon> Create(u32 index);

View File

@ -49,7 +49,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
NeGconRumble(u32 index); explicit NeGconRumble(u32 index);
~NeGconRumble() override; ~NeGconRumble() override;
static std::unique_ptr<NeGconRumble> Create(u32 index); static std::unique_ptr<NeGconRumble> Create(u32 index);
@ -148,4 +148,4 @@ private:
float m_steering_deadzone = 0.00f; float m_steering_deadzone = 0.00f;
float m_steering_sensitivity = 1.00f; float m_steering_sensitivity = 1.00f;
}; };

View File

@ -23,7 +23,7 @@ public:
static const Controller::ControllerInfo INFO; static const Controller::ControllerInfo INFO;
PlayStationMouse(u32 index); explicit PlayStationMouse(u32 index);
~PlayStationMouse() override; ~PlayStationMouse() override;
static std::unique_ptr<PlayStationMouse> Create(u32 index); static std::unique_ptr<PlayStationMouse> Create(u32 index);

View File

@ -78,7 +78,7 @@ class ControllerMacroWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
ControllerMacroWidget(ControllerBindingWidget* parent); explicit ControllerMacroWidget(ControllerBindingWidget* parent);
~ControllerMacroWidget(); ~ControllerMacroWidget();
void updateListItem(u32 index); void updateListItem(u32 index);
@ -133,7 +133,7 @@ class ControllerCustomSettingsWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
ControllerCustomSettingsWidget(ControllerBindingWidget* parent); explicit ControllerCustomSettingsWidget(ControllerBindingWidget* parent);
~ControllerCustomSettingsWidget(); ~ControllerCustomSettingsWidget();
void createSettingWidgets(ControllerBindingWidget* parent, QWidget* parent_widget, QGridLayout* layout, void createSettingWidgets(ControllerBindingWidget* parent, QWidget* parent_widget, QGridLayout* layout,

View File

@ -20,7 +20,7 @@ class DebuggerCodeModel final : public QAbstractTableModel
Q_OBJECT Q_OBJECT
public: public:
DebuggerCodeModel(QObject* parent = nullptr); explicit DebuggerCodeModel(QObject* parent = nullptr);
~DebuggerCodeModel() override; ~DebuggerCodeModel() override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@ -61,7 +61,7 @@ class DebuggerRegistersModel final : public QAbstractListModel
Q_OBJECT Q_OBJECT
public: public:
DebuggerRegistersModel(QObject* parent = nullptr); explicit DebuggerRegistersModel(QObject* parent = nullptr);
~DebuggerRegistersModel() override; ~DebuggerRegistersModel() override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@ -82,7 +82,7 @@ class DebuggerStackModel final : public QAbstractListModel
Q_OBJECT Q_OBJECT
public: public:
DebuggerStackModel(QObject* parent = nullptr); explicit DebuggerStackModel(QObject* parent = nullptr);
~DebuggerStackModel() override; ~DebuggerStackModel() override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override;
@ -98,7 +98,7 @@ class DebuggerAddBreakpointDialog final : public QDialog
Q_OBJECT Q_OBJECT
public: public:
DebuggerAddBreakpointDialog(QWidget* parent = nullptr); explicit DebuggerAddBreakpointDialog(QWidget* parent = nullptr);
~DebuggerAddBreakpointDialog() override; ~DebuggerAddBreakpointDialog() override;
u32 getAddress() const { return m_address; } u32 getAddress() const { return m_address; }

View File

@ -3,7 +3,6 @@
#pragma once #pragma once
#include <QtCore/QSemaphore>
#include <QtCore/QThread> #include <QtCore/QThread>
#include "common/progress_callback.h" #include "common/progress_callback.h"
@ -14,7 +13,7 @@ class GameListRefreshThread;
class AsyncRefreshProgressCallback : public ProgressCallback class AsyncRefreshProgressCallback : public ProgressCallback
{ {
public: public:
AsyncRefreshProgressCallback(GameListRefreshThread* parent); explicit AsyncRefreshProgressCallback(GameListRefreshThread* parent);
float timeSinceStart() const; float timeSinceStart() const;
@ -46,7 +45,7 @@ class GameListRefreshThread final : public QThread
Q_OBJECT Q_OBJECT
public: public:
GameListRefreshThread(bool invalidate_cache); explicit GameListRefreshThread(bool invalidate_cache);
~GameListRefreshThread(); ~GameListRefreshThread();
float timeSinceStart() const; float timeSinceStart() const;
@ -58,7 +57,7 @@ Q_SIGNALS:
void refreshComplete(); void refreshComplete();
protected: protected:
void run(); void run() final;
private: private:
AsyncRefreshProgressCallback m_progress; AsyncRefreshProgressCallback m_progress;

View File

@ -1037,7 +1037,7 @@ namespace {
class GameListCenterIconStyleDelegate final : public QStyledItemDelegate class GameListCenterIconStyleDelegate final : public QStyledItemDelegate
{ {
public: public:
GameListCenterIconStyleDelegate(QWidget* parent) : QStyledItemDelegate(parent) {} explicit GameListCenterIconStyleDelegate(QWidget* parent) : QStyledItemDelegate(parent) {}
~GameListCenterIconStyleDelegate() = default; ~GameListCenterIconStyleDelegate() = default;
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override

View File

@ -210,7 +210,7 @@ class GameListWidget final : public QWidget
Q_OBJECT Q_OBJECT
public: public:
GameListWidget(QWidget* parent = nullptr); explicit GameListWidget(QWidget* parent = nullptr);
~GameListWidget(); ~GameListWidget();
ALWAYS_INLINE GameListModel* getModel() const { return m_model; } ALWAYS_INLINE GameListModel* getModel() const { return m_model; }

View File

@ -17,7 +17,7 @@ class InputBindingWidget : public QPushButton
Q_OBJECT Q_OBJECT
public: public:
InputBindingWidget(QWidget* parent); explicit InputBindingWidget(QWidget* parent);
InputBindingWidget(QWidget* parent, SettingsInterface* sif, InputBindingInfo::Type bind_type, InputBindingWidget(QWidget* parent, SettingsInterface* sif, InputBindingInfo::Type bind_type,
std::string section_name, std::string key_name); std::string section_name, std::string key_name);
~InputBindingWidget(); ~InputBindingWidget();
@ -76,7 +76,7 @@ class InputVibrationBindingWidget : public QPushButton
Q_OBJECT Q_OBJECT
public: public:
InputVibrationBindingWidget(QWidget* parent); explicit InputVibrationBindingWidget(QWidget* parent);
InputVibrationBindingWidget(QWidget* parent, ControllerSettingsWindow* dialog, std::string section_name, InputVibrationBindingWidget(QWidget* parent, ControllerSettingsWindow* dialog, std::string section_name,
std::string key_name); std::string key_name);
~InputVibrationBindingWidget(); ~InputVibrationBindingWidget();

View File

@ -12,7 +12,7 @@ class ISOBrowserWindow : public QWidget
Q_OBJECT Q_OBJECT
public: public:
ISOBrowserWindow(QWidget* parent = nullptr); explicit ISOBrowserWindow(QWidget* parent = nullptr);
~ISOBrowserWindow(); ~ISOBrowserWindow();
static ISOBrowserWindow* createAndOpenFile(QWidget* parent, const QString& path); static ISOBrowserWindow* createAndOpenFile(QWidget* parent, const QString& path);

View File

@ -281,7 +281,7 @@ public:
using DeviceList = QList<Device>; using DeviceList = QList<Device>;
InputDeviceListModel(QObject* parent = nullptr); explicit InputDeviceListModel(QObject* parent = nullptr);
~InputDeviceListModel() override; ~InputDeviceListModel() override;
// Safe to access on UI thread. // Safe to access on UI thread.
@ -325,7 +325,7 @@ Q_SIGNALS:
void completed(QtAsyncTask* self); void completed(QtAsyncTask* self);
private: private:
QtAsyncTask(WorkCallback callback); explicit QtAsyncTask(WorkCallback callback);
std::variant<WorkCallback, CompletionCallback> m_callback; std::variant<WorkCallback, CompletionCallback> m_callback;
}; };

View File

@ -16,7 +16,7 @@ class QtModalProgressCallback final : public QObject, public ProgressCallback
Q_OBJECT Q_OBJECT
public: public:
QtModalProgressCallback(QWidget* parent_widget, float show_delay = 0.0f); explicit QtModalProgressCallback(QWidget* parent_widget, float show_delay = 0.0f);
~QtModalProgressCallback(); ~QtModalProgressCallback();
QProgressDialog& GetDialog() { return m_dialog; } QProgressDialog& GetDialog() { return m_dialog; }
@ -53,7 +53,7 @@ class QtAsyncProgressThread : public QThread, public ProgressCallback
Q_OBJECT Q_OBJECT
public: public:
QtAsyncProgressThread(QWidget* parent); explicit QtAsyncProgressThread(QWidget* parent);
~QtAsyncProgressThread(); ~QtAsyncProgressThread();
bool IsCancelled() const override; bool IsCancelled() const override;

View File

@ -14,7 +14,7 @@ class SelectDiscDialog final : public QDialog
Q_OBJECT Q_OBJECT
public: public:
SelectDiscDialog(const std::string& disc_set_name, QWidget* parent = nullptr); explicit SelectDiscDialog(const std::string& disc_set_name, QWidget* parent = nullptr);
~SelectDiscDialog(); ~SelectDiscDialog();
ALWAYS_INLINE const std::string& getSelectedDiscPath() { return m_selected_path; } ALWAYS_INLINE const std::string& getSelectedDiscPath() { return m_selected_path; }

View File

@ -10,7 +10,7 @@
class Updater class Updater
{ {
public: public:
Updater(ProgressCallback* progress); explicit Updater(ProgressCallback* progress);
~Updater(); ~Updater();
bool Initialize(std::string staging_directory, std::string destination_directory); bool Initialize(std::string staging_directory, std::string destination_directory);

View File

@ -28,7 +28,7 @@ namespace {
class TrackFileInterface class TrackFileInterface
{ {
public: public:
TrackFileInterface(std::string filename); explicit TrackFileInterface(std::string filename);
virtual ~TrackFileInterface(); virtual ~TrackFileInterface();
ALWAYS_INLINE const std::string& GetFileName() const { return m_filename; } ALWAYS_INLINE const std::string& GetFileName() const { return m_filename; }

View File

@ -172,7 +172,7 @@ IMPLEMENT_ENUM_CLASS_BITWISE_OPERATORS(GPUDriverType);
class GPUShader class GPUShader
{ {
public: public:
GPUShader(GPUShaderStage stage); explicit GPUShader(GPUShaderStage stage);
virtual ~GPUShader(); virtual ~GPUShader();
static const char* GetStageName(GPUShaderStage stage); static const char* GetStageName(GPUShaderStage stage);

View File

@ -114,7 +114,7 @@ void ClearStages(SettingsInterface& si, const char* section);
class Chain final class Chain final
{ {
public: public:
Chain(const char* section); explicit Chain(const char* section);
~Chain(); ~Chain();
ALWAYS_INLINE bool HasStages() const { return !m_stages.empty(); } ALWAYS_INLINE bool HasStages() const { return !m_stages.empty(); }

View File

@ -27,7 +27,7 @@ class Shader
{ {
public: public:
Shader(); Shader();
Shader(std::string name); explicit Shader(std::string name);
virtual ~Shader(); virtual ~Shader();
ALWAYS_INLINE const std::string& GetName() const { return m_name; } ALWAYS_INLINE const std::string& GetName() const { return m_name; }
@ -64,4 +64,4 @@ protected:
OptionList m_options; OptionList m_options;
}; };
} // namespace PostProcessing } // namespace PostProcessing