How to determine whether a class has a particular templated member function?

烂漫一生 提交于 2019-12-05 09:31:20

There is something similar already implemented in Boost.MPL, it is called "BOOST_MPL_HAS_XXX_TRAIT_DEF". See:

http://www.boost.org/doc/libs/1_41_0/libs/mpl/doc/refmanual/has-xxx-trait-def.html

It can detect if the class have a given named type.

Also, for your specific case, instead of passing the function pointer as a parameter (void (_t::*)()), try to use it in the body of your method, i.e., something like:

template < typename _t >
static big test( sfinae<_t> )
{
  &_t::foo<_n>;
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!