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
| struct SData | |
| { | |
| int m_Size; | |
| char *m_Buf; | |
| SData() | |
| : m_Size(0), m_Buf(nullptr) | |
| { | |
| puts("ctor"); | |
| } |
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
| int i(int()); // int i( int a ) 함수선언으로 인식. | |
| i = 2; // COMPILE ERR, int 변수가 아니라서 대입불가 |
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
| // 이동 생성자/연산자는 RVO 및 int x(int())의 버그를 고려하고 학습/테스트 해야 한다. | |
| class CTest { | |
| public: | |
| CTest() { puts("ctor"); } | |
| CTest(const CTest &rRight) { puts("ctor-c"); } // copy | |
| CTest(CTest &&rrRight) { puts("ctor-m"); } // move | |
| CTest & operator=(const CTest &rRight) { puts("assign"); return *this; } // copy (일반적으로 딥카피) | |
| CTest & operator=(CTest &&rrRight) noexcept { puts("assign-m"); return *this; } // move | |
| static CTest Create_NoRVO(const int n) { return n ? CTest() : CTest(); } |
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 | |
| { |
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() = default; | |
| }; | |
| CTest *pTest = nullptr; | |
| { | |
| CTest &&rrInt = CTest(); | |
| pTest = &rrInt; | |
| } // ~CTestwekj() |
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 CCaseA { | |
| public: | |
| CCaseA() = delete; | |
| }; | |
| class CCaseB { | |
| public: | |
| CCaseB() = default; | |
| CCaseB & operator =(const CCaseB &) = delete; | |
| }; |
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
| int a = 1, b = 2; | |
| [&] // capture local variables as &a, &b | |
| { | |
| a = 3; // &a = 3 | |
| b = 4; | |
| }(); // instant execution | |
| [=] // capture local variables const a, const b | |
| { |
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 CBase { | |
| virtual void f() {} | |
| }; | |
| class CDerieve : public CBase { | |
| virtual void f() override {} | |
| }; | |
| void CastTest() | |
| { | |
| // dynamic cast with reference |
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
| #pragma pack(push) | |
| #pragma pack(1) | |
| struct SRefTest | |
| { | |
| char a; | |
| char b; | |
| char &r; | |
| SRefTest() : a(1), b(2), r(a) {} | |
| }; |
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
| int add(int a, int b) { return a + b; } | |
| void FuncRefTest() | |
| { | |
| int(*pfnAdd)(int a, int b) = add; | |
| pfnAdd(1, 2); | |
| (*pfnAdd)(1, 2); | |
| pfnAdd = add; // ok | |
| int(&rfnAdd)(int a, int b) = add; |