#include <iostream>
#include <string>
#include <vector>

using namespace std;

namespace {

// address to number
unsigned a2n(void *addr)
{
  static std::vector<void*> addr_list;

  unsigned i = 0;
  for(; i < addr_list.size(); ++i) {
    if(addr_list[i] == addr) {
      return i;
    }
  }
  addr_list.push_back(addr);
  return i;
}

// number to string
std::string n2s(unsigned n)
{
  switch(n) {
  case 0:
    return "x";
  case 1:
    return "tmp";
  case 2:
    return "y";
  default:
    return "none";
  }
}

struct Hoge
{
  Hoge()
  {
    cout << "Hoge : default constructor. (" << n2s(a2n(this)) << ")" << endl;
  }

  ~Hoge()
  {
    cout << "Hoge : destructor. (" << n2s(a2n(this)) << ")" << endl;
  }

  Hoge(const Hoge& o)
  {
    cout << "Hoge : copy constructor. (" << n2s(a2n((void*)&o)) << ") -> (" << n2s(a2n(this)) << ")" << endl;
  }

  Hoge(Hoge&& o)
  {
    cout << "Hoge : move constructor. (" << n2s(a2n((void*)&o)) << ") -> (" << n2s(a2n(this)) << ")" << endl;
  }

  Hoge&& foo()
  {
    Hoge tmp(*this);
    return std::move(tmp);
  }
};

} // namespace

int main()
{
  Hoge x;
  Hoge y = x.foo();
}
