Merge pull request #37388 from CurtizJ/explicit-bool-operator

Mark all `operator bool()` as explicit
This commit is contained in:
Alexey Milovidov 2022-05-22 00:18:19 +03:00 committed by GitHub
commit 4bfbb0b7ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 9 additions and 9 deletions

View File

@ -219,7 +219,7 @@ protected:
/// Get internal immutable ptr. Does not change internal use counter. /// Get internal immutable ptr. Does not change internal use counter.
immutable_ptr<T> detach() && { return std::move(value); } immutable_ptr<T> detach() && { return std::move(value); }
operator bool() const { return value != nullptr; } /// NOLINT explicit operator bool() const { return value != nullptr; }
bool operator! () const { return value == nullptr; } bool operator! () const { return value == nullptr; }
bool operator== (const chameleon_ptr & rhs) const { return value == rhs.value; } bool operator== (const chameleon_ptr & rhs) const { return value == rhs.value; }

View File

@ -169,7 +169,7 @@ struct StringHashTableLookupResult
auto & operator*() const { return *this; } auto & operator*() const { return *this; }
auto * operator->() { return this; } auto * operator->() { return this; }
auto * operator->() const { return this; } auto * operator->() const { return this; }
operator bool() const { return mapped_ptr; } /// NOLINT explicit operator bool() const { return mapped_ptr; }
friend bool operator==(const StringHashTableLookupResult & a, const std::nullptr_t &) { return !a.mapped_ptr; } friend bool operator==(const StringHashTableLookupResult & a, const std::nullptr_t &) { return !a.mapped_ptr; }
friend bool operator==(const std::nullptr_t &, const StringHashTableLookupResult & b) { return !b.mapped_ptr; } friend bool operator==(const std::nullptr_t &, const StringHashTableLookupResult & b) { return !b.mapped_ptr; }
friend bool operator!=(const StringHashTableLookupResult & a, const std::nullptr_t &) { return a.mapped_ptr; } friend bool operator!=(const StringHashTableLookupResult & a, const std::nullptr_t &) { return a.mapped_ptr; }

View File

@ -161,7 +161,7 @@ public:
task_info->deactivate(); task_info->deactivate();
} }
operator bool() const { return task_info != nullptr; } /// NOLINT explicit operator bool() const { return task_info != nullptr; }
BackgroundSchedulePoolTaskInfo * operator->() { return task_info.get(); } BackgroundSchedulePoolTaskInfo * operator->() { return task_info.get(); }
const BackgroundSchedulePoolTaskInfo * operator->() const { return task_info.get(); } const BackgroundSchedulePoolTaskInfo * operator->() const { return task_info.get(); }

View File

@ -108,7 +108,7 @@ public:
/// Approximate number of allocated bytes in memory - for profiling and limits. /// Approximate number of allocated bytes in memory - for profiling and limits.
size_t allocatedBytes() const; size_t allocatedBytes() const;
operator bool() const { return !!columns(); } /// NOLINT explicit operator bool() const { return !!columns(); }
bool operator!() const { return !this->operator bool(); } /// NOLINT bool operator!() const { return !this->operator bool(); } /// NOLINT
/** Get a list of column names separated by commas. */ /** Get a list of column names separated by commas. */

View File

@ -90,7 +90,7 @@ public:
bool hasRows() const { return num_rows > 0; } bool hasRows() const { return num_rows > 0; }
bool hasColumns() const { return !columns.empty(); } bool hasColumns() const { return !columns.empty(); }
bool empty() const { return !hasRows() && !hasColumns(); } bool empty() const { return !hasRows() && !hasColumns(); }
operator bool() const { return !empty(); } /// NOLINT explicit operator bool() const { return !empty(); }
void addColumn(ColumnPtr column); void addColumn(ColumnPtr column);
void addColumn(size_t position, ColumnPtr column); void addColumn(size_t position, ColumnPtr column);

View File

@ -88,7 +88,7 @@ void ParallelParsingInputFormat::parserThreadFunction(ThreadGroupStatusPtr threa
// We don't know how many blocks will be. So we have to read them all // We don't know how many blocks will be. So we have to read them all
// until an empty block occurred. // until an empty block occurred.
Chunk chunk; Chunk chunk;
while (!parsing_finished && (chunk = parser.getChunk()) != Chunk()) while (!parsing_finished && (chunk = parser.getChunk()))
{ {
/// Variable chunk is moved, but it is not really used in the next iteration. /// Variable chunk is moved, but it is not really used in the next iteration.
/// NOLINTNEXTLINE(bugprone-use-after-move, hicpp-invalid-access-moved) /// NOLINTNEXTLINE(bugprone-use-after-move, hicpp-invalid-access-moved)

View File

@ -1480,7 +1480,7 @@ bool TCPHandler::receiveUnexpectedData(bool throw_exception)
maybe_compressed_in = in; maybe_compressed_in = in;
auto skip_block_in = std::make_shared<NativeReader>(*maybe_compressed_in, client_tcp_protocol_version); auto skip_block_in = std::make_shared<NativeReader>(*maybe_compressed_in, client_tcp_protocol_version);
bool read_ok = skip_block_in->read(); bool read_ok = !!skip_block_in->read();
if (!read_ok) if (!read_ok)
state.read_all_data = true; state.read_all_data = true;

View File

@ -29,7 +29,7 @@ struct MergeTreeIndexFormat
MergeTreeIndexVersion version; MergeTreeIndexVersion version;
const char* extension; const char* extension;
operator bool() const { return version != 0; } /// NOLINT explicit operator bool() const { return version != 0; }
}; };
/// Stores some info about a single block of data. /// Stores some info about a single block of data.

View File

@ -22,7 +22,7 @@ struct StoragesInfo
bool need_inactive_parts = false; bool need_inactive_parts = false;
MergeTreeData * data = nullptr; MergeTreeData * data = nullptr;
operator bool() const { return storage != nullptr; } /// NOLINT explicit operator bool() const { return storage != nullptr; }
MergeTreeData::DataPartsVector MergeTreeData::DataPartsVector
getParts(MergeTreeData::DataPartStateVector & state, bool has_state_column, bool require_projection_parts = false) const; getParts(MergeTreeData::DataPartStateVector & state, bool has_state_column, bool require_projection_parts = false) const;
}; };