Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-09-23 14:02:13


"Terence Wilson" <tez_at_[hidden]> wrote in message
news:002501c2632e$8405c010$0b01a8c0_at_TerenceWilson.com...
> Can't you use:
>
> template < typename T > void f(T* ptr )
> {
> T& ref = *ptr;
> // ... do something with ref ...
> }

Not if he wants to use a smart pointer. He could overload it for known
smart pointers, or define an interface, like so:

template < typename T > void f(T* ptr )
{
    T& ref = *ptr;
    // ... do something with ref ...
}

template < typename T > void f(some_ptr<T> ptr )
{
    some_ptr<T>::reference_type ref = *ptr;
    // ... do something with ref ...
}

But then, if there were a pointer traits class, he wouldn't have to provide
the overloads.

Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk