Edit: Sorry, this question is a duplicate. Original: SFINAE to check for inherited member functions
I have a templated function (in a class used for testing):
template <class CHandler>
void InitHandler(CHandler &handler)
{
handler.setId(0);
handler.SetCache(m_pCache.get());
handler.m_pScience = m_pScience;
}
However it is possible that this function will may be called with a template argument that doesn't have an m_pScience member.
Can I use template metaprogramming to only set this member if it exists ?