lundi 1 août 2016

can I use SFINAE to selectively define a member variable in a template class?

So what I want to do is to create a template class which may or may not contain a member variable based on the template argument passed in. like following:

template<typename T, bool flag>
class base
{
   foov<std::enable_if<flag, T>::type> m_var;
};

the above code could not survive the compiler.

Does anyone know how I can achieve this?

Aucun commentaire:

Enregistrer un commentaire