From 09fb6dac5139f923d85f62c6336936f475d920d2 Mon Sep 17 00:00:00 2001 From: Chunel Date: Tue, 23 Jun 2026 23:57:13 +0800 Subject: [PATCH] [feat] Add bool function for CStatus --- python/PyCGraph.cpp | 1 + src/CBasic/CStatus.h | 4 ++++ src/UtilsCtrl/ThreadPool/UThreadPoolConfig.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python/PyCGraph.cpp b/python/PyCGraph.cpp index 7bd05254..98c24e8c 100644 --- a/python/PyCGraph.cpp +++ b/python/PyCGraph.cpp @@ -129,6 +129,7 @@ PYBIND11_MODULE(pycgraph, cg) { py::arg("errorInfo")) .def("__iadd__", &CStatus::operator+=, py::return_value_policy::reference) + .def("__bool__", &CStatus::operator bool) .def("getCode", &CStatus::getCode) .def("getInfo", &CStatus::getInfo) .def("reset", &CStatus::reset) diff --git a/src/CBasic/CStatus.h b/src/CBasic/CStatus.h index 91878c89..d43e4063 100644 --- a/src/CBasic/CStatus.h +++ b/src/CBasic/CStatus.h @@ -81,6 +81,10 @@ class CSTATUS { return (*this); } + explicit operator bool() const { + return this->isOK(); + } + /** * 恢复状态信息 */ diff --git a/src/UtilsCtrl/ThreadPool/UThreadPoolConfig.h b/src/UtilsCtrl/ThreadPool/UThreadPoolConfig.h index da00ea40..76a19ae8 100644 --- a/src/UtilsCtrl/ThreadPool/UThreadPoolConfig.h +++ b/src/UtilsCtrl/ThreadPool/UThreadPoolConfig.h @@ -62,7 +62,7 @@ struct UThreadPoolConfig : public CStruct { * @return */ int calcStealRange() const { - int range = (std::min)(this->max_task_steal_range_, this->default_thread_size_ - 1); + const int range = (std::min)(this->max_task_steal_range_, this->default_thread_size_ - 1); return range; }