[Effective Modern C++] 항목 32. 객체를 클로저 안으로 이동하려면 초기화 갈무리를 사용하라
이동 전용 객체들을 클로저 안으로 이동시키야 하는 경우를 알아보도록 하자. C++14 부터 새로운 갈무리 메커니즘을 도입하였다. 초기화 갈무리라는 것으로 다음과 같은 것을 할 수 있다. class Widget { public: ... bool isValidated() const; bool isProcessed() const; bool isArchived() const; private: ... }; auto pw = std::make_unique(); ... auto func = [pw = std::move(pw)] { return pw->isValidated() && pw->isArchived(); }; 마지막 줄에 캡쳐절이 초기화 갈무리라는 것이다. 재미있게도 좌변과 우변의 범위가 다른데, 좌변은 클로..
C++/Effective Modern C++
2020. 1. 12. 17:23
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Effective
- C++
- detach
- Modern
- Override
- 발아시기
- MOVE
- Join
- forward
- 포인터
- CPP
- C++14
- std::move
- Unreal
- Overloading
- 보편 참조
- Forwarding
- C++11
- Future
- thread
- auto
- const
- Perfect
- async
- C
- 다이소
- Effective Modern C++
- 보편참조
- 람다
- std::forward
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
글 보관함