[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppScopedArray
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppScopedArray
(C++) boost::scoped_array
a smart pointer available in the Boost C++ Library. It enables you to dynamically create an array that goes out of scope automatically.
//Standard way
{
const int size = rand()%69;
int * myPlainArray = new int[size];
//Code
delete[] myPlainArray;
}
//Using the boost::scoped_array
{
boost::scoped_array<int> myArray(rand()%69);
//Code
//Nothing! myArray deletes[] itself when going out of scope!
}
Why is the boost::scoped_array not in the STL, where std::auto_ptr is ?
On the website of Bjarne Stroustrup he stated that the boost::scoped_array was not necessary. I guess, this is because a std::vector can be used instead, which has similar behaviour.Link
- http://www.boost.org/
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
