#ifndef ELFSPY_RESULT_H #define ELFSPY_RESULT_H #include "elfspy/Variadic.h" #include "elfspy/Thunk.h" #include "elfspy/ThunkHandle.h" #include "elfspy/Capture.h" namespace spy { /** * @namespace spy * @class Result * This captures the return value of an invocation */ template class Result : public Thunk, public Capture { public: virtual void invoke(ReturnType&& result) override; }; template void Result::invoke(ReturnType&& result) { // forward arguments to avoid copying this->captures_.push_back(std::forward(result)); } template inline auto result(H& hook) -> ThunkHandle> { return hook.return_thunks(); } template inline auto new_result(H& hook) -> ThunkHandle>* { return new ThunkHandle(hook.return_thunks()); } } // namespace elfspy #endif