From 4e8b0ea9d5473c4e382433957a830b9c108a59fa Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Mon, 13 May 2024 16:53:03 +0800 Subject: [PATCH] some fix --- include/pocketpy/common.h | 1 - include/pocketpy/vm.h | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/pocketpy/common.h b/include/pocketpy/common.h index 82a775f4..e065cf63 100644 --- a/include/pocketpy/common.h +++ b/include/pocketpy/common.h @@ -103,7 +103,6 @@ struct Type { bool operator==(Type other) const { return this->index == other.index; } bool operator!=(Type other) const { return this->index != other.index; } constexpr operator int() const { return index; } - constexpr operator bool() const { return index != 0; } }; #define PK_LAMBDA(x) ([](VM* vm, ArgsView args) { return x; }) diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 4071a9e5..9012017f 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -494,7 +494,7 @@ PyVar py_var(VM* vm, __T&& value){ return from_void_p(vm, (void*)value); }else{ constexpr Type const_type = _find_type_in_const_cxx_typeid_map(); - if constexpr(const_type){ + if constexpr((bool)const_type){ if constexpr(is_sso_v) return PyVar(const_type, value); else return vm->heap.gcnew(const_type, std::forward<__T>(value)); } @@ -550,7 +550,7 @@ __T _py_cast__internal(VM* vm, PyVar obj) { return to_void_p(vm, obj); }else{ constexpr Type const_type = _find_type_in_const_cxx_typeid_map(); - if constexpr(const_type){ + if constexpr((bool)const_type){ if constexpr(with_check){ if constexpr(std::is_same_v){ // Exception is `subclass_enabled`