[C++] Boost's scoped_array

Started by
10 comments, last by GameDev.net 18 years, 10 months ago
Quote:Original post by MaulingMonkey
std::vector hints that you may be reallocating, boost::scoped_array hints that you probably are not.

This is the big thing I was trying to get at. scoped_array is a static array, while vector is a dynamic one. In terms of performance, I don't see there being a difference. *edit: Except in the realm of custom allocators, which I know nothing about.

CM
Advertisement
Quote:Original post by Conner McCloud
scoped_array does not resize the array, ever.
What I meant was this:
scoped_array pFeatureButtons; //"array size=0" (points to 0)
pFeatureButtons.reset( new HWND[count] ); //array size=count

std::vector would do basically the same allocations here, but the new call is just hidden inside the resize call.
Quote:It serves an entirely different job than vector.
It seemed that in this case pFeatureButtons was simply mimicing a dynamic array. The question now was only if std::vector was supposed to have this performance penalty over scoped_array or not.

This topic is closed to new replies.

Advertisement