#include <cstdlib>

#include <iostream>  // cout
#include <memory>    // unique_ptr
#include <string>    // string

using std::string;
using std::unique_ptr;
using std::cout;

string ReturnString(void) {
  string x("World");
  return x;  // this return might copy (depends on compiler)
}

int main(int argc, char** argv) {
  // utilizing move semantics with unique_ptr's
  unique_ptr<string> a(new string("Hello"));

  // moves a to b
  unique_ptr<string> b = std::move(a);
  // a is now nullptr (default constructor of unique_ptr)
  std::cout << "b: " << *b << std::endl;  // "Hello"

  // move semantics with strings
  string c("Hello");

  // moves the return value into b (done explicitly)
  c = std::move(ReturnString());
  std::cout << "c: " << c << std::endl;  // "World"

  return EXIT_SUCCESS;
}