I want to use std::vector for dynamically allocating memory. The scenario is:
int neededLength = computeLength(); // some logic here
// this will allocate t
If you're using std::vector just for its RAII properties (so that it will free the memory for you), and you don't actually need it to resize or anything, you might be better off using a Boost scoped_array
boost::scoped_array buffer( new TCHAR[neededLength] );
callFunction( buffer.get(), neededLength );
scoped_array will call delete[] on the array when it goes out of scope.