From a2648dda97454efdc8c785d83cf039f6d2383e9e Mon Sep 17 00:00:00 2001 From: Regina Pfeifer Date: Mon, 19 Nov 2018 23:35:09 +0100 Subject: Mark operator bool explicit --- Source/cmArchiveWrite.h | 8 +------- Source/cmCTest.h | 2 +- Source/cmELF.h | 2 +- Source/cmMachO.h | 2 +- Source/cmQtAutoGenInitializer.h | 2 +- Source/cmSystemTools.cxx | 5 ++++- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 6c678ac..6ecdd63 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -40,9 +40,6 @@ private: */ class cmArchiveWrite { - typedef void (cmArchiveWrite::*safe_bool)(); - void safe_bool_true() {} - public: /** Compression type. */ enum Compress @@ -73,10 +70,7 @@ public: bool recursive = true); /** Returns true if there has been no error. */ - operator safe_bool() const - { - return this->Okay() ? &cmArchiveWrite::safe_bool_true : nullptr; - } + explicit operator bool() const { return this->Okay(); } /** Returns true if there has been an error. */ bool operator!() const { return !this->Okay(); } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 427049d..9139e42 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -66,7 +66,7 @@ public: const std::string& GetName() const { return this->Name; } void Enable() { this->Enabled = true; } - operator bool() const { return this->Enabled; } + explicit operator bool() const { return this->Enabled; } std::vector SubmitFiles; diff --git a/Source/cmELF.h b/Source/cmELF.h index 9172f38..c8a91e4 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -32,7 +32,7 @@ public: std::string const& GetErrorMessage() const { return this->ErrorMessage; } /** Boolean conversion. True if the ELF file is valid. */ - operator bool() const { return this->Valid(); } + explicit operator bool() const { return this->Valid(); } /** Enumeration of ELF file types. */ enum FileType diff --git a/Source/cmMachO.h b/Source/cmMachO.h index 5886d76..5482465 100644 --- a/Source/cmMachO.h +++ b/Source/cmMachO.h @@ -30,7 +30,7 @@ public: std::string const& GetErrorMessage() const; /** Boolean conversion. True if the Mach-O file is valid. */ - operator bool() const { return this->Valid(); } + explicit operator bool() const { return this->Valid(); } /** Get Install name from binary **/ bool GetInstallName(std::string& install_name); diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 903ec85..d817848 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -54,7 +54,7 @@ public: InfoWriter(std::string const& filename); /// @return True if the file is open - operator bool() const { return static_cast(Ofs_); } + explicit operator bool() const { return static_cast(Ofs_); } void Write(const char* text) { Ofs_ << text; } void Write(const char* key, std::string const& value); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 9866d13..28aa57c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -137,7 +137,10 @@ public: CloseHandle(this->handle_); } } - operator bool() const { return this->handle_ != INVALID_HANDLE_VALUE; } + explicit operator bool() const + { + return this->handle_ != INVALID_HANDLE_VALUE; + } bool operator!() const { return this->handle_ == INVALID_HANDLE_VALUE; } operator HANDLE() const { return this->handle_; } -- cgit v0.12