lundi 3 décembre 2018

Conditional function behavior based on pointer-ness of template type

I'm trying to come up with a member function for a template class that:

  • does something in case the template type is a pointer
  • does nothing for non-pointers

Not sure if SFINAE applies to this, since I need both versions as I call them in the class itself. Please note I'm limited to C++11.

template < typename T_ = T, typename = std::enable_if_t <!std::is_pointer<T_>{} > >
void SomeFunction()
{
    // Do nothing
}
template < typename T_ = T, typename = std::enable_if_t < std::is_pointer<T_>{} > >
void SomeFunction()
{
    // Do sth
}

Compiler complains that error C2535: member function already defined or declared.

Aucun commentaire:

Enregistrer un commentaire