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

View File

@ -19,7 +19,7 @@ public:
DynamicLibrary();
/// 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.
DynamicLibrary(DynamicLibrary&& move);

View File

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

View File

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

View File

@ -8,7 +8,7 @@
class PerfScope
{
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]); }
void Register(const void* ptr, size_t size, const char* symbol);

View File

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

View File

@ -32,7 +32,7 @@ namespace {
class CheatFileReader
{
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 GetCurrentLineOffset() const { return m_current_line_offset; }
@ -178,7 +178,7 @@ public:
};
public:
CheatCode(Metadata metadata);
explicit CheatCode(Metadata metadata);
virtual ~CheatCode();
ALWAYS_INLINE const Metadata& GetMetadata() const { return m_metadata; }
@ -2034,7 +2034,7 @@ namespace {
class GamesharkCheatCode final : public CheatCode
{
public:
GamesharkCheatCode(Metadata metadata);
explicit GamesharkCheatCode(Metadata metadata);
~GamesharkCheatCode() override;
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_BUTTON_DEADZONE = 0.25f;
Controller(u32 index);
explicit Controller(u32 index);
virtual ~Controller();
/// Returns the type of controller.

View File

@ -57,7 +57,7 @@ public:
static const Controller::ControllerInfo INFO;
DDGoController(u32 index);
explicit DDGoController(u32 index);
~DDGoController() override;
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
{
public:
BackgroundProgressCallback(std::string name);
explicit BackgroundProgressCallback(std::string name);
~BackgroundProgressCallback() override;
void SetStatusText(const std::string_view text) override;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1037,7 +1037,7 @@ namespace {
class GameListCenterIconStyleDelegate final : public QStyledItemDelegate
{
public:
GameListCenterIconStyleDelegate(QWidget* parent) : QStyledItemDelegate(parent) {}
explicit GameListCenterIconStyleDelegate(QWidget* parent) : QStyledItemDelegate(parent) {}
~GameListCenterIconStyleDelegate() = default;
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
public:
GameListWidget(QWidget* parent = nullptr);
explicit GameListWidget(QWidget* parent = nullptr);
~GameListWidget();
ALWAYS_INLINE GameListModel* getModel() const { return m_model; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@ class Shader
{
public:
Shader();
Shader(std::string name);
explicit Shader(std::string name);
virtual ~Shader();
ALWAYS_INLINE const std::string& GetName() const { return m_name; }