Newsgroup: comp.lang.c++
Subject: calling placement new for elements of a deque
From: hbdevelop1@...
Date: Wed, 26 Feb 2014 21:50:29 -0800 (PST)
Hello
For optimisation reasons, I am re-using not used objects in my deque for new objects.
I am doing that this way :
void Score::Add(const char *str, Coordinates &sp)
{
for(deque<Text>::iterator it=scores.begin();it!=scores.end(); ++it)
{
if(it->notUsed==1)
{
it->Reset(str,sp);
return;
}
}
scores.push_back(Text(str,sp));
}
I thought it would be more convenient to call the placement new on the notUsed object instead of Reset.
How can I do this ?
How can I get the address of the not used object so I can use it in the new placement operator?
Thank you in advance
Subject: calling placement new for elements of a deque
From: hbdevelop1@...
Date: Wed, 26 Feb 2014 21:50:29 -0800 (PST)
Hello
For optimisation reasons, I am re-using not used objects in my deque for new objects.
I am doing that this way :
void Score::Add(const char *str, Coordinates &sp)
{
for(deque<Text>::iterator it=scores.begin();it!=scores.end(); ++it)
{
if(it->notUsed==1)
{
it->Reset(str,sp);
return;
}
}
scores.push_back(Text(str,sp));
}
I thought it would be more convenient to call the placement new on the notUsed object instead of Reset.
How can I do this ?
How can I get the address of the not used object so I can use it in the new placement operator?
Thank you in advance
via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://ift.tt/1cWtAxS
View all the progranning help forums at:
http://ift.tt/1dP9txN
No comments:
Post a Comment