first of all, as mentioned by @jrok and the post you linked to:
you have to have a template function to use enable_if
. but it is not a good idea in your particular case, because there is no reason to do this operator->
templated. moreover, it wouldn't work! cuz there is no way to instantiate a particular operator->()! it doesn't have (and can't) any parameters and there is no syntax to specify it when you call it on some object! so, T
(or whateve dummy type) will/could not be deduced from this call.
so, as a workaround you may use compile-time conditional inheritance. i.e. smth like this:
template <typename T, bool IsClass>
struct smart_base
{
struct base {};
};
template <typename T>
struct smart_base<T, true>
{
struct base
{
T* operator->()
{
// do that ever you wanted to do
}
};
};
template <typename T>
struct smart : public smart_base<T, std::is_class<T>::value>::base
{
// depending on T here you have, or have no operator-> inherited
};
you have to understand, that having operator->
actually in your base class will require to move some function and/or data members to base-of-the-base class :) or you may use CRTP technique to access members of a derived class from the base one :)