Skip to content

Instantly share code, notes, and snippets.

@Garciat
Created January 2, 2015 16:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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