#ifndef ELFSPY_ARG_H #define ELFSPY_ARG_H #include "elfspy/Variadic.h" #include "elfspy/Thunk.h" #include "elfspy/ThunkHandle.h" #include "elfspy/Capture.h" namespace spy { /** * @namespace spy * @class Arg * This captures one argument of an invocation */ template class Arg : public Thunk, public Capture::Type> { public: virtual void invoke(ArgTypes&&... args) override; }; template void Arg::invoke(ArgTypes&&... args) { using Var = Variadic; // forward arguments to avoid copying this->captures_.push_back(Var::get(std::forward(args)...)); } template inline auto arg(H& hook) -> ThunkHandle::template Type> { return hook.thunks(); } template inline auto new_arg(H& hook) -> ThunkHandle::template Type>* { using TP = ThunkHandle::template Type>; return new TP(hook.thunks()); } } // namespace elfspy #endif