#include <algorithm>
#include <functional>
#include <iostream>

class A
{
    std::reference_wrapper<int> r;
public:
   A(int& v) : r(v) {}
   void swap(A& rhs)
   {
      std::swap(r, rhs.r);
   }

   int& get() const { return r; }
};

int main()
{
    int i = 42;
    int j = 0;
    A a(i), b(j);

    a.swap(b);
    ++j;
    std::cout << j << "==" << a.get() << std::endl;
    return 0;
}
