diff --git a/src/c_wrapper/error.h b/src/c_wrapper/error.h index e847a1a068993ff24495ae7fdfdf3c33332cb82e..aadc02a5371e9f2c000dd74060d05329d652270e 100644 --- a/src/c_wrapper/error.h +++ b/src/c_wrapper/error.h @@ -152,6 +152,18 @@ struct __CLCall { template class CLArgPack : public ArgPack { + template void + _print_trace(T &res, const char *name) + { + typename CLArgPack::tuple_base *that = this; + std::cerr << name << "("; + __CLCall<__CLPrint, sizeof...(Types) - 1, + decltype(*that)>::call(*that, std::cerr); + std::cerr << ") = (" << res << ", "; + __CLCall<__CLPrintOut, sizeof...(Types) - 1, + decltype(*that)>::call(*that, std::cerr); + std::cerr << ")" << std::endl; + } public: using ArgPack::ArgPack; template @@ -161,14 +173,7 @@ public: { auto res = this->template call<__CLArgGetter>(func); if (DEBUG_ON) { - typename CLArgPack::tuple_base *that = this; - std::cerr << name << "("; - __CLCall<__CLPrint, sizeof...(Types) - 1, - decltype(*that)>::call(*that, std::cerr); - std::cerr << ") = (" << res << ", "; - __CLCall<__CLPrintOut, sizeof...(Types) - 1, - decltype(*that)>::call(*that, std::cerr); - std::cerr << ")" << std::endl; + _print_trace(res, name); } return res; }