I'm trying to write a class that logs calls to its operator=
but I don't know of away to do it without changing the calling code. For a function whose signature I could adjust, something like this might work: How to know what function called another, but I don't see how that would work for a function like operator=
. Is this possible?
Example class/usage:
template <typename T>
class LoggingT {
T data;
LoggingT& operator=(const LoggingT& rhs){
data = rhs;
std::cout << "assigned at line: "
<< ???? << " in file " << ???? << std::endl;
return *this;
};