$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Trevor Perrin (tperrin_at_[hidden])
Date: 2001-03-02 14:04:23
Hello,
I was wondering if there's a way to modify boost::shared_ptr to give it
similar const semantics to "raw" pointers, i.e if
int x;
const shared_ptr<int> a(&x);
shared_ptr<int> b=a;
could be made to fail to compile for the same reason that
int x;
const int* a = &x;
int* b = &x;
does; cause you're trying to do a "conversion that loses qualifiers". I
tried fiddling with it; I guess you want to express "non-const objects can't
be constructed with const ones", but I couldn't figure out how to do that.
For example, shared_ptr<const int> didn't work (I'm using VC6 sp4) cause you
can't delete the pointer; maybe you could specialize shared_ptr for const
types or something, but I'm not sure if that works for VC and I'm sort of
over my head here. So if anyone knows if such a thing is possible, and if
so how to go about it, I'd love to hear it..