c++ - var arg list to tempfile, why is it needed? -


I have this code inside a code constructor (not written by me) and it writes a RAP list in a TMP File is

I wonder why this will be needed? After exiting this ctor, the tmpfile is removed and the var arg list sits inside the m_str vector.

Can anyone recommend a better way of doing this without the use of a tmpfile?

Destring (const char * fmt, ...) {DLog :: instance () - & gt; Logs ("inside the entrance with the ellipses"); Va_list varptr; Va_start (varptr, fmt); File * f = tmpfile (); If (f! = Null) {int n = :: vfprintf (f, fmt, varptr) + 1; M_str.resize (n + 1); :: vsprintf (& amp; m_str [0], FMT, Veerpritter); Va_end (varptr); } Other DLog :: Example () - & gt; Log ("[Error TMPFILE:] Unable to create TmpFile for request!"); }

This is the C ++ code: I think that you solve the wrong problem Trying to get here

If you consider using the series, then the requirement of the temp file will be completely removed. It may seem like a lot of work to change all calling sites to use a new mechanism, but the Vergegaz offers different types of possibilities to mislead you, which opens to you hypocrite bugs. , Not in the non-all POD type I believe in a long (or even medium) period that it is easy to pay for credibility, clarity and debugging Will do

Instead of trying to implement a C ++ - style stream interface that provides type protection and even capability to reject some actions if necessary.


Comments