Boost logo

Boost :

From: Andrew D Jewell (ajewell_at_[hidden])
Date: 2000-03-13 10:25:51


>I believe this already works fine without adding new classes. In what way is
>const_scoped_ptr<X> superior to scoped_ptr<const X>?

class qualified_scoped_ptr {
          T * operator -> () throw() { return p; }
    const T * operator -> () const throw() { return p; }
}
class scoped_ptr {
    T * operator -> () const throw() { return p; }
}

class X {
    void f();
};

some_function()
{
    const scoped_ptr<X> spx;
    const qualified_scoped_ptr<X> qspx;

     spx->f(); // OK
    qspx->f(); // compile error (or warning) : non-const method on const object.
}

does that answer your question?
Andy Jewell


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