
24 Feb
2009
24 Feb
'09
7:21 p.m.
2009/2/23 Alexander
WFM...
void foo(scoped_array<int> &b) { scoped_array<int> a(new int[5]); swap(a,b); // escape }
Hm.. I agree with you that having swap to escape scoping but not having release looks inconsequent. In my opinion there should be no swap either.
Without swap(), there will be need for another smart pointer. I use swap to swap two array pointers (so I'm using scoped_array) in my computations. Without it, I don't know how I would write it in an efficient way. Matthieu -- Information System Engineer, Ph.D. Website: http://matthieu-brucher.developpez.com/ Blogs: http://matt.eifelle.com and http://blog.developpez.com/?blog=92 LinkedIn: http://www.linkedin.com/in/matthieubrucher