Make all operator bool const and nonexcept.
This commit is contained in:
parent
445cd4118d
commit
683627a350
@ -496,7 +496,7 @@ class SecretChatActor final : public NetQueryCallback {
|
|||||||
public:
|
public:
|
||||||
Change() : message_id() {
|
Change() : message_id() {
|
||||||
}
|
}
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return !data.empty();
|
return !data.empty();
|
||||||
}
|
}
|
||||||
explicit Change(const StateT &state) {
|
explicit Change(const StateT &state) {
|
||||||
|
@ -145,7 +145,7 @@ FileNode *FileNodePtr::get_unsafe() const {
|
|||||||
return file_manager_->get_file_node_raw(file_id_);
|
return file_manager_->get_file_node_raw(file_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNodePtr::operator bool() const {
|
FileNodePtr::operator bool() const noexcept {
|
||||||
return file_manager_ != nullptr && get_unsafe() != nullptr;
|
return file_manager_ != nullptr && get_unsafe() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ class FileNodePtr {
|
|||||||
FileNode &operator*() const;
|
FileNode &operator*() const;
|
||||||
FileNode *get() const;
|
FileNode *get() const;
|
||||||
FullRemoteFileLocation *get_remote() const;
|
FullRemoteFileLocation *get_remote() const;
|
||||||
explicit operator bool() const;
|
explicit operator bool() const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FileId file_id_;
|
FileId file_id_;
|
||||||
@ -229,7 +229,7 @@ class ConstFileNodePtr {
|
|||||||
return file_node_ptr_.operator*();
|
return file_node_ptr_.operator*();
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return static_cast<bool>(file_node_ptr_);
|
return static_cast<bool>(file_node_ptr_);
|
||||||
}
|
}
|
||||||
const FullRemoteFileLocation *get_remote() const {
|
const FullRemoteFileLocation *get_remote() const {
|
||||||
|
@ -24,7 +24,7 @@ class NetQueryCounter {
|
|||||||
counter->fetch_add(1, std::memory_order_relaxed);
|
counter->fetch_add(1, std::memory_order_relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return static_cast<bool>(ptr_);
|
return static_cast<bool>(ptr_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class SslStream {
|
|||||||
size_t flow_read(MutableSlice slice);
|
size_t flow_read(MutableSlice slice);
|
||||||
size_t flow_write(Slice slice);
|
size_t flow_write(Slice slice);
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return static_cast<bool>(impl_);
|
return static_cast<bool>(impl_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ struct RawCancellationToken {
|
|||||||
|
|
||||||
class CancellationToken {
|
class CancellationToken {
|
||||||
public:
|
public:
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
// empty CancellationToken is never canceled
|
// empty CancellationToken is never canceled
|
||||||
if (!token_) {
|
if (!token_) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -36,7 +36,7 @@ namespace td {
|
|||||||
template <int shift>
|
template <int shift>
|
||||||
struct MaskIterator {
|
struct MaskIterator {
|
||||||
uint64 mask;
|
uint64 mask;
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return mask != 0;
|
return mask != 0;
|
||||||
}
|
}
|
||||||
int pos() const {
|
int pos() const {
|
||||||
|
@ -158,7 +158,7 @@ class MpscLinkQueueUniquePtrNode {
|
|||||||
return MpscLinkQueueUniquePtrNode<Value>(unique_ptr<Value>(Value::from_mpsc_link_queue_node(node)));
|
return MpscLinkQueueUniquePtrNode<Value>(unique_ptr<Value>(Value::from_mpsc_link_queue_node(node)));
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() {
|
explicit operator bool() const noexcept {
|
||||||
return ptr_ != nullptr;
|
return ptr_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ class Promise {
|
|||||||
Promise(F &&f) : promise_(detail::promise_interface_ptr<T>(std::forward<F>(f))) {
|
Promise(F &&f) : promise_(detail::promise_interface_ptr<T>(std::forward<F>(f))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() {
|
explicit operator bool() const noexcept {
|
||||||
return static_cast<bool>(promise_);
|
return static_cast<bool>(promise_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,10 +123,10 @@ class SharedPtr {
|
|||||||
other.raw_ = nullptr;
|
other.raw_ = nullptr;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool empty() const {
|
bool empty() const noexcept {
|
||||||
return raw_ == nullptr;
|
return raw_ == nullptr;
|
||||||
}
|
}
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return !empty();
|
return !empty();
|
||||||
}
|
}
|
||||||
uint64 use_cnt() const {
|
uint64 use_cnt() const {
|
||||||
@ -255,7 +255,7 @@ class SharedObjectPool {
|
|||||||
Raw *get() const {
|
Raw *get() const {
|
||||||
return raw_;
|
return raw_;
|
||||||
}
|
}
|
||||||
explicit operator bool() const {
|
explicit operator bool() noexcept {
|
||||||
return raw_ != nullptr;
|
return raw_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class Timestamp {
|
|||||||
return is_in_past(now_cached());
|
return is_in_past(now_cached());
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return at_ > 0;
|
return at_ > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class optional {
|
|||||||
optional &operator=(optional &&other) = default;
|
optional &operator=(optional &&other) = default;
|
||||||
~optional() = default;
|
~optional() = default;
|
||||||
|
|
||||||
explicit operator bool() const {
|
explicit operator bool() const noexcept {
|
||||||
return impl_.is_ok();
|
return impl_.is_ok();
|
||||||
}
|
}
|
||||||
T &value() {
|
T &value() {
|
||||||
|
@ -156,7 +156,7 @@ NativeFd::~NativeFd() {
|
|||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeFd::operator bool() const {
|
NativeFd::operator bool() const noexcept {
|
||||||
return fd_ != empty_fd();
|
return fd_ != empty_fd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class NativeFd {
|
|||||||
NativeFd &operator=(NativeFd &&other) noexcept;
|
NativeFd &operator=(NativeFd &&other) noexcept;
|
||||||
~NativeFd();
|
~NativeFd();
|
||||||
|
|
||||||
explicit operator bool() const;
|
explicit operator bool() const noexcept;
|
||||||
|
|
||||||
Fd fd() const;
|
Fd fd() const;
|
||||||
Socket socket() const;
|
Socket socket() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user