5 Sep
2006
5 Sep
'06
8:59 p.m.
Stephan Tolksdorf <andorxor@gmx.de> writes:
Hi
why doesn't shared_array allow the same conversions as shared_ptr, so that
boost::shared_ptr<int> ip; boost::shared_ptr<const int> ip2(ip);
is allowed, but not
boost::shared_array<int> ip; boost::shared_array<const int> ip2(ip);
Probably because that particular case wasn't anticipated. It was deemed important to prevent this: struct B { int x; }; struct D : B { int y; }; boost::shared_array<D> p1(new D[20]); boost::shared_array<B> p2(p1); p2[1]; // oops!
Is it safe to use shared_ptr's with arrays if one supplies an array deleter as a constructor argument?
Yeah, if you consider allowing my oops example to be "safe"... -- Dave Abrahams Boost Consulting www.boost-consulting.com