C++ visit
#include <iostream> struct Output { int m_i{8}; template<typename F> void visit(F& f) { f(this->m_i); } template<typename F> void visit(F& f) const { f(this->m_i); } }; typedef int (* Func) (int a); int fun(int a) { std::cout<< a << std::endl; return a; } int main() { Output ot; Func f = fun; ot.visit<Func>(f); return 0; }
标签:std,int,void,visit,C++,template From: https://www.cnblogs.com/liangzige/p/16824429.html