I would like to write a wrapper class with all operators overloaded such that I can detect when we write/read or modify its contents. For instance:
probe<int> x; x = 5; // write if(x) { // read x += 7; // modify }
Anyone already did that? If not which operators must I overload to be sure I dont miss anything?
You can’t, I think. operator?: isn’t overloadable. Also, if
T::T(int)is defined,T foo = 4is legal butT foo = probe<int>(4)isn’t. There’s at most one user-defined conversion.Furthermore, because probe is not a POD, the behavior of your program can change.