D
Dave
#ifndef INCLUDED
#define INCLUDED
#include <fstream>
// Instantiate the template below with these constants.
const unsigned int LOG_1 = 0;
const unsigned int LOG_2 = 1;
// ...
template <unsigned int>
std:fstream &Log()
{
static std:fstream Strm;
return Strm;
}
#endif
Am I guaranteed that every translation unit that calls, for example,
Log<LOG_1>(), will get a reference to the exact same stream object?
I seem to recall that there are some unusual cases where a static object can
end up being created more than once...
#define INCLUDED
#include <fstream>
// Instantiate the template below with these constants.
const unsigned int LOG_1 = 0;
const unsigned int LOG_2 = 1;
// ...
template <unsigned int>
std:fstream &Log()
{
static std:fstream Strm;
return Strm;
}
#endif
Am I guaranteed that every translation unit that calls, for example,
Log<LOG_1>(), will get a reference to the exact same stream object?
I seem to recall that there are some unusual cases where a static object can
end up being created more than once...