6 Jun
2007
6 Jun
'07
6:09 p.m.
For a template class I'd like to add * and -> operators for types that support it (mainly pointers). However, most instantiations of this class won't be pointers and therefore these operators won't be valid. I understand that enable_if can't directly support member functions. But, how can I do the equivalent of this? template< typename T > class Sample { T data; public: Sample( T& data ) : data(data) { } typename boost::enable_if< boost::is_pointer<T>, T >::type operator->() const { return(data); } typename boost::enable_if< boost::is_pointer<T>, typename boost::remove_pointer<T>::type >::type operator*() const { return(*data); } };