Created
January 31, 2018 06:25
-
-
Save fortheday/138af1eceabd6907edf0df7070356f9c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class CTest { | |
public: | |
CTest() { puts("ctor"); } | |
CTest(CTest &&rrRight) { puts("ctor-m"); } // move | |
CTest & operator=(CTest &&rrRight) noexcept { puts("assign-m"); return *this; } // move | |
CTest & operator=(CTest &rRight) { puts("assign"); return *this; } // copy (일반적으로 딥카피) | |
}; | |
auto createTest1 = []() -> CTest | |
{ | |
CTest test; | |
return test; | |
}; | |
auto createTest2 = []() -> CTest | |
{ | |
return CTest(); | |
}; | |
CTest test1 = createTest1(); // NRVO(/O2)적용시 (1)ctor 미적용시 (1)ctor (2)ctor-m | |
CTest test2 = createTest2(); // RVO. (1)ctor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment