I would like to do something like the following pattern:
T* const pT = findT();
T* const pT2 = new T( *pT );
delete pT;
I know that I can finish the area by completing the block, but it ends as follows:
T* pT2 = 0;
{
T* const pT = findT();
pT2 = new T( *pT );
delete pT;
}
This causes pT2 to lose its const qualifier, because I need to assign it after it is declared.
I need my cake, and I also want to eat it, I want a clear confidence and the right scope!
Is there a way to end the scope of a variable other than block completion? If not, do you plan to expand the standard to support this?
source
share