Created
May 4, 2024 00:47
-
-
Save virtuosonic/d4dbcdb23adbce5c449e282ad17fe225 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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