Hi
 
Me and my colleagues have come across an issue when using a shared_ptr.
 
void myFunction(shared_ptr<myClass> const & vp_Pointer)
{
            vp_Pointer->call any non-const function
}
 
i.e. a const shared_ptr doesn't prevent anyone from changing the
contents to which the pointer points. This makes sense as it behaves
like a normal pointer.
 
However, how can I pass a shared pointer into a function such that the
data can not be modified? i.e. how can I pass an equivalent of "myClass
const *" ?
 
I tried static casting to shared_ptr<const myClass> which works but
causes a new constructor to be called which means I loose the efficiency
of passing by reference.
 
Any comments of suggestions would be greatly appreciated.
 
Martin Bosticky
Software Engineer
Action Information Management Ltd.
Tel: (01225) 711200
Fax: (01225) 711222
Email: [EMAIL PROTECTED]
 


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to