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