Just playing around a little with C++. What I really want to do is to be able to setup a function with default values defined for an array or pointer argument. To keep thing
One simple way to do this is via plain old function overloading. For example, below simulates the default parameter value for format parameter which is char* type:
static string to_string(time_point time)
{
return to_string(time, "%Y-%m-%d-%H-%M-%S");
}
static string to_string(time_point time, const char* format)
{
time_t tt = system_clock::to_time_t(time);
char str[1024];
if (std::strftime(str, sizeof(str), format, std::localtime(&tt)))
return string(str);
else return string();
}