Skip to content

Instantly share code, notes, and snippets.

@Garciat
Created January 2, 2015 16:37
Show Gist options
  • Save Garciat/b4ffb71c2f4561a8fdd7 to your computer and use it in GitHub Desktop.
Save Garciat/b4ffb71c2f4561a8fdd7 to your computer and use it in GitHub Desktop.
struct meow {
static int defaults;
static int copies;
static int moves;
static int destroys;
static void report() {
std::cout << "defaults: " << defaults << std::endl;
std::cout << "copies: " << copies << std::endl;
std::cout << "moves: " << moves << std::endl;
std::cout << "destroys: " << destroys << std::endl;
}
bool moved = false;
meow() {
std::cout << __PRETTY_FUNCTION__ << std::endl;
++defaults;
}
meow(const meow&) {
std::cout << __PRETTY_FUNCTION__ << std::endl;
++copies;
}
meow(meow&& rhs) {
std::cout << __PRETTY_FUNCTION__ << std::endl;
rhs.moved = true;
++moves;
}
~meow() {
std::cout << __PRETTY_FUNCTION__;
if (!moved) {
std::cout << " (not moved!)";
}
std::cout << std::endl;
++destroys;
}
};
int meow::defaults = 0;
int meow::copies = 0;
int meow::moves = 0;
int meow::destroys = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment