Add explicit identifier to some constructors (#5652)

If a class has a constructor which can be called with a single argument,
then this constructor becomes conversion constructor because such a
constructor allows conversion of the single argument to the class being
constructed. To ensure these constructors are passed the argument of its
type, I labeled them explicit.

In some header files, there were constructors that took a value that
could involve implicit conversions, so I added explicit to ensure that
does not happen.
This commit is contained in:
pi1024e 2020-04-29 19:50:47 -04:00 committed by GitHub
parent 10fa3108e1
commit fb22eae072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 12 additions and 11 deletions

View file

@ -32,7 +32,8 @@ namespace winrt::TerminalApp::implementation
struct ActionEventArgs : public ActionEventArgsT<ActionEventArgs> struct ActionEventArgs : public ActionEventArgsT<ActionEventArgs>
{ {
ActionEventArgs() = default; ActionEventArgs() = default;
ActionEventArgs(const TerminalApp::IActionArgs& args) :
explicit ActionEventArgs(const TerminalApp::IActionArgs& args) :
_ActionArgs{ args } {}; _ActionArgs{ args } {};
GETSET_PROPERTY(IActionArgs, ActionArgs, nullptr); GETSET_PROPERTY(IActionArgs, ActionArgs, nullptr);
GETSET_PROPERTY(bool, Handled, false); GETSET_PROPERTY(bool, Handled, false);

View file

@ -46,7 +46,7 @@ class TerminalApp::CascadiaSettings final
{ {
public: public:
CascadiaSettings(); CascadiaSettings();
CascadiaSettings(const bool addDynamicProfiles); explicit CascadiaSettings(const bool addDynamicProfiles);
static std::unique_ptr<CascadiaSettings> LoadDefaults(); static std::unique_ptr<CascadiaSettings> LoadDefaults();
static std::unique_ptr<CascadiaSettings> LoadAll(); static std::unique_ptr<CascadiaSettings> LoadAll();

View file

@ -12,7 +12,7 @@ namespace winrt::Microsoft::TerminalApp::implementation
class DebugTapConnection : public winrt::implements<DebugTapConnection, winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection> class DebugTapConnection : public winrt::implements<DebugTapConnection, winrt::Microsoft::Terminal::TerminalConnection::ITerminalConnection>
{ {
public: public:
DebugTapConnection(Microsoft::Terminal::TerminalConnection::ITerminalConnection wrappedConnection); explicit DebugTapConnection(Microsoft::Terminal::TerminalConnection::ITerminalConnection wrappedConnection);
~DebugTapConnection(); ~DebugTapConnection();
void Start(); void Start();
void WriteInput(hstring const& data); void WriteInput(hstring const& data);

View file

@ -202,7 +202,7 @@ private:
std::unique_ptr<LayoutSizeNode> nextFirstChild; std::unique_ptr<LayoutSizeNode> nextFirstChild;
std::unique_ptr<LayoutSizeNode> nextSecondChild; std::unique_ptr<LayoutSizeNode> nextSecondChild;
LayoutSizeNode(const float minSize); explicit LayoutSizeNode(const float minSize);
LayoutSizeNode(const LayoutSizeNode& other); LayoutSizeNode(const LayoutSizeNode& other);
LayoutSizeNode& operator=(const LayoutSizeNode& other); LayoutSizeNode& operator=(const LayoutSizeNode& other);

View file

@ -48,7 +48,7 @@ class TerminalApp::Profile final
{ {
public: public:
Profile(); Profile();
Profile(const std::optional<GUID>& guid); explicit Profile(const std::optional<GUID>& guid);
~Profile(); ~Profile();

View file

@ -47,7 +47,7 @@ namespace TerminalApp
class SettingsException : public std::runtime_error class SettingsException : public std::runtime_error
{ {
public: public:
SettingsException(const SettingsLoadErrors& error) : explicit SettingsException(const SettingsLoadErrors& error) :
std::runtime_error{ nullptr }, std::runtime_error{ nullptr },
_error{ error } {}; _error{ error } {};

View file

@ -18,7 +18,7 @@ Abstract:
class ConsoleInputReader class ConsoleInputReader
{ {
public: public:
ConsoleInputReader(HANDLE handle); explicit ConsoleInputReader(HANDLE handle);
void SetWindowSizeChangedCallback(std::function<void()> callback); void SetWindowSizeChangedCallback(std::function<void()> callback);
std::optional<std::wstring_view> Read(); std::optional<std::wstring_view> Read();

View file

@ -20,7 +20,7 @@ Author:
class CommandNumberPopup final : public Popup class CommandNumberPopup final : public Popup
{ {
public: public:
CommandNumberPopup(SCREEN_INFORMATION& screenInfo); explicit CommandNumberPopup(SCREEN_INFORMATION& screenInfo);
[[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override; [[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;

View file

@ -20,7 +20,7 @@ Author:
class CopyFromCharPopup final : public Popup class CopyFromCharPopup final : public Popup
{ {
public: public:
CopyFromCharPopup(SCREEN_INFORMATION& screenInfo); explicit CopyFromCharPopup(SCREEN_INFORMATION& screenInfo);
[[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override; [[nodiscard]] NTSTATUS Process(COOKED_READ_DATA& cookedReadData) noexcept override;

View file

@ -34,7 +34,7 @@ public:
SMALL_RECT rcViewCaWindow; SMALL_RECT rcViewCaWindow;
COORD coordConView; COORD coordConView;
ConversionAreaBufferInfo(const COORD coordBufferSize); explicit ConversionAreaBufferInfo(const COORD coordBufferSize);
}; };
class ConversionAreaInfo final class ConversionAreaInfo final

View file

@ -22,7 +22,7 @@ struct _HSL
double h, s, l; double h, s, l;
// constructs an HSL color from a RGB Color. // constructs an HSL color from a RGB Color.
_HSL(const COLORREF rgb) explicit _HSL(const COLORREF rgb)
{ {
const double r = (double)GetRValue(rgb); const double r = (double)GetRValue(rgb);
const double g = (double)GetGValue(rgb); const double g = (double)GetGValue(rgb);