Skip to content

Instantly share code, notes, and snippets.

@cppio
Created February 15, 2019 02:05
Show Gist options
  • Save cppio/476b820516b9e76be1185fb3f00512f5 to your computer and use it in GitHub Desktop.
Save cppio/476b820516b9e76be1185fb3f00512f5 to your computer and use it in GitHub Desktop.
Simple C++ class that logs all constructions, destructions, and assignments.
#include <iostream>
class Test {
public:
Test() { std::cout << __PRETTY_FUNCTION__ << std::endl; }
Test(Test const&) { std::cout << __PRETTY_FUNCTION__ << std::endl; }
Test(Test&&) { std::cout << __PRETTY_FUNCTION__ << std::endl; }
~Test() { std::cout << __PRETTY_FUNCTION__ << std::endl; }
Test& operator=(Test const&) { std::cout << __PRETTY_FUNCTION__ << std::endl; return *this; }
Test& operator=(Test&&) { std::cout << __PRETTY_FUNCTION__ << std::endl; return *this; }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment