template <typename>
struct Functor;
template <typename Return, typename... Args>
struct Functor<Return(Args...)> {
private:
struct BaseWrapper {
Return (*call)(BaseWrapper* wrapper, Args... args) = nullptr;
};
template <typename Invocable>
struct Wrapper : BaseWrapper {
std::decay_t<Invocable> inv;
static PLY_NO_INLINE Return call(BaseWrapper* wrapper, Args... args) {
return static_cast<Wrapper*>(wrapper)->inv(std::forward<Args>(args)...);
}
template <typename I>
PLY_INLINE Wrapper(I&& inv) : BaseWrapper{&call}, inv{std::forward<I>(inv)} {
}
};
BaseWrapper* wrapper = nullptr;
public:
PLY_INLINE Functor() = default;
PLY_INLINE Functor(Functor&& other) : wrapper{other.wrapper} {
other.wrapper = nullptr;
}
PLY_INLINE bool isValid() const {
return this->wrap
plywood的functor类
最新推荐文章于 2024-09-08 09:58:56 发布