class ProfileScope {
public:
ProfileScope(...) { // start measurement }
~ProfileScope() { // stop measurement }
};
It accesses global variables. It's used like:
void f()
{
ProfileScope xxx("f() scope");
//...
}
The problem is that VS optimizes the destruction of xxx and does it right after creation or maybe later but 100% not at the end of the scope. Is there a way to prevent it?