
6 Jun
2007
6 Jun
'07
12:23 p.m.
On 06/06/07, Bill Buklis <boostuser@pbjzone.com> wrote:
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?
[code snipped]
SFINAE -- you don't even need boost: template <typename T> struct holder { T value; T operator->() const { return value; } }; struct foo { int bar; }; int main() { holder<foo*> a; // compiles a->bar = 0; // compiles holder<int> b; // compiles // b->bar = 0; // wouldn't compile } ~ Scott McMurray