class TestA
{
public:
void Get(int a, int b) { std::cout << a <<std::endl; }
};
template<class _Editor, class _Ret, class ..._Arg>
_Ret GOElevationFollowsBoard(_Ret(_Editor::* pMemFunc)(_Arg...), std::remove_cv_t<_Arg>... args)
{
_Editor spEditor;
if constexpr (std::is_same_v<_Ret, void>)
{
(spEditor.*pMemFunc)(std::forward<_Arg>(args)...);
}
else
{
return (spEditor.*pMemFunc)(std::forward<_Arg>(args)...);
}
}
int main() {
int a = 10, b = 20;
GOElevationFollowsBoard(&TestA::Get,a,b);
return 0;
}
模板调用类中函数方法
最新推荐文章于 2024-06-19 20:37:33 发布