I have a templated function called from multiple other functions that needs to log the name of the function from which it was called. Ideally, I want to do something like the following:
template <typename T, const char* CALLER>
void foo(const T& arg) {
// ...
}
However, this does not compile, of course, as CALLER
is an invalid template parameter. Of course, I could simply modify the signature of foo
to also take in a string (the caller's name) to achieve this.
Question: Is there a preferred C++ idiomatic way to achieve this sort of thing?