Skip to content

Instantly share code, notes, and snippets.

@virtuosonic
Created May 4, 2024 00:47
Show Gist options
  • Save virtuosonic/d4dbcdb23adbce5c449e282ad17fe225 to your computer and use it in GitHub Desktop.
Save virtuosonic/d4dbcdb23adbce5c449e282ad17fe225 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
struct S {
S() {cout << "S::S() " << id << "\n";}
S(const S&) {cout << "S::S(const S&) " << id << "\n";}
S(S&&) {cout << "S::S(const S&&) " << id << "\n";}
S& operator=(const S& other) { cout << "S::operator=(const S& other) " << id << "\n";return *this;}
S& operator=(S&& other) { cout << "S::operator=(const S&& other) " << id << "\n";return *this;}
~S(){ cout << "S::~S()"<< id <<"\n";}
static unsigned last_id;
unsigned id{last_id++};
};
unsigned S::last_id = 0;
int main()
{
S s;
S s1 = s;
S& ref = s;
S s2 = move(s);
s = S();
s = move(s1);
S s3;
constexpr uint8_t stoprecord = 0;
cout << << "qwewqewe\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment