瀏覽代碼

Update any.h

blueloveTH 2 年之前
父節點
當前提交
e8830e6407
共有 1 個文件被更改,包括 0 次插入27 次删除
  1. 0 27
      include/pocketpy/any.h

+ 0 - 27
include/pocketpy/any.h

@@ -103,31 +103,4 @@ struct function<Ret(Params...)>{
     }
 };
 
-template<typename T>
-struct lightfunction;
-
-template<typename Ret, typename... Params>
-struct lightfunction<Ret(Params...)>{
-    void* _impl;
-    Ret (*_wrapper)(void*, Params...);
-
-    lightfunction() : _impl(nullptr), _wrapper(nullptr) {}
-
-    explicit operator bool() const { return _wrapper != nullptr; }
-
-    template<typename F>
-    lightfunction(const F& f){
-        _impl = (F*)(&f);
-        _wrapper = [](void* impl, Params... params) -> Ret{
-            F* f = (F*)(impl);
-            return (*f)(std::forward<Params>(params)...);
-        };
-    }
-
-    Ret operator()(Params... params) const{
-        if(!_wrapper) throw std::runtime_error("empty function");
-        return _wrapper(_impl, std::forward<Params>(params)...);
-    }
-};
-
 } // namespace pkpy