Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Copy elision sample modern C++
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <iostream> #define _(X) std::cout<<"\""#X<<"\"\t==>\t"; X #define I_LIKE_TO_MOVE_IT #undef I_LIKE_TO_MOVE_IT class CDog { public: CDog() = default; CDog(const CDog&){std::cout<<"copied\n";} CDog& operator=(CDog& other){std::cout<<"copied =\n"; return other;} #ifdef I_LIKE_TO_MOVE_IT CDog(CDog&&){std::cout<<"moved\n";} CDog& operator=(CDog&& other){std::cout<<"moved =\n"; return std::move(other);} #endif virtual ~CDog(){} }; int main() { CDog& myDog = CDog(); CDog& yourDog = CDog(); _(yourDog = std::move(myDog);) _(myDog = CDog(std::move(yourDog));) return 0; }
run
|
edit
|
history
|
help
0
std::is_same doesn't check for calling convention
Initializing member array of structs
Unicode_write2file
additional layer of indirection
variable template not supported
VC++ error LNK2001 with combined use of non-type template parameters
unresolved external symbol
My Window
Not an overflow
SO typeindex pretty_name