#include <iostream>
#include <cstring>

struct String {
	char *buf;
	size_t size;

	String () : buf(0), size(0){}
	~String () {
		std::cout << "release " << (void*)buf << std::endl;
		delete [] buf; 
	}
	String (char *s) {
		size = strlen(s)+1;
		buf = new char[size];
		strcpy (buf, s);
		std::cout << "allocated at " << (void*)buf << std::endl;
	}
	String (String&& o) : buf(o.buf), size(o.size) { o.buf = 0; o.size = 0; }
	String (const String& o) : buf(new char[o.size]), size(o.size) {
		strcpy (buf, o.buf);
		std::cout << "allocated at " << (void*)buf << std::endl;
	}
};

void foo (String&& s) {
	std::cout << s.buf << std::endl;
}

int main() {
	foo (String ("test"));
	
	String a("test1");
	String b(std::move(a));

	return 0;
}