#include <iostream>

template <class T>
class Logger
{
  T value;

public:

  T& operator=(const T& other)
  {
    std::cout << "Setting new value\n";
    value = other;
    return value;
  }

  operator T() const
  {
    return value;
  }

};

class Foo
{
public:
    Foo() {}

    void SetBar(int value)
    {
        //Log that m_bar is going to be changed
        m_bar = value;
    }

private:

#if 1
    Logger<int> m_bar; // the variable we want to track
#else
    int m_bar; // the variable we want to track
#endif

};

int main()
{
  auto f = Foo();
  f.SetBar(12);
}