Mark operator bool explicit

This commit is contained in:
Regina Pfeifer
2018-11-19 23:35:09 +01:00
parent 1dc85a6652
commit a2648dda97
6 changed files with 9 additions and 12 deletions

View File

@@ -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(); }

View File

@@ -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<std::string> SubmitFiles;

View File

@@ -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

View File

@@ -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);

View File

@@ -54,7 +54,7 @@ public:
InfoWriter(std::string const& filename);
/// @return True if the file is open
operator bool() const { return static_cast<bool>(Ofs_); }
explicit operator bool() const { return static_cast<bool>(Ofs_); }
void Write(const char* text) { Ofs_ << text; }
void Write(const char* key, std::string const& value);

View File

@@ -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_; }