#include <iostream>
#include <stdexcept>
struct Foo
{
  Foo(const Foo&) { std::cout << "Foo(const Foo&)\n";}
  Foo(Foo&&) { std::cout << "Foo(Foo&&)\n";}
  Foo() { std::cout << "Foo()\n";}
  Foo& operator=(const Foo&) { 
    std::cout << "operator=(const Foo&)\n";
    return *this;
  }
  Foo& operator=(Foo&&) { 
    std::cout << "operator=(Foo&&)\n";
    return *this;
  }
};

Foo foo(int i)
{
  if (i<0)
  {
    throw std::out_of_range("Foo fail!");
  }
  else
  {
    return Foo();
  }
}

int main()
{
  Foo f = foo(1);
}
