From 83ca79e5f764f18a20cc941d8f0f1705b4b11f44 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 4 May 2024 13:59:59 +0800 Subject: [PATCH] some fix --- include/pocketpy/vm.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/pocketpy/vm.h b/include/pocketpy/vm.h index 304ad736..c4f3a086 100644 --- a/include/pocketpy/vm.h +++ b/include/pocketpy/vm.h @@ -351,11 +351,14 @@ public: mod->attr().set(name, type); _cxx_typeid_map[typeid(T)] = PK_OBJ_GET(Type, type); T::_register(vm, mod, type); - if(!type->attr().contains(__new__)){ - bind_func(type, __new__, -1, [](VM* vm, ArgsView args){ - vm->NotImplementedError(); - return vm->None; - }); + // check if T is trivially constructible + if constexpr(!std::is_default_constructible_v){ + if(!type->attr().contains(__new__)){ + bind_func(type, __new__, -1, [](VM* vm, ArgsView args){ + vm->NotImplementedError(); + return vm->None; + }); + } } return type; }