[Effective Modern C++] 항목 3. decltype의 작동 방식을 숙지하라
decltype 이라는 키워드는 객체가 주어졌을때, 그 객체의 타입을 알려준다. 예시를 보자. const int i = 0; // decltype(i)는 const int MyClass object; // decltype(object)는 MyClass 위와 같이 객체의 타입을 알려주는데, 가끔 생각한대로 동작하지 않는 경우가 있다. 특이한 작동 방식 먼저 코드를 보자. template auto authAndAccess(Container& c, Index i) -> decltype(c[i]) { authenticateUser(); return c[i]; } 위에서 보이는 함수처럼 auto 와 decltype 을 이용한 방식을 후행 반환 형식이라고 한다. 후행 반환 형식으로 선언한 함수의 반환 타입은 dec..
C++/Effective Modern C++
2019. 9. 2. 21:19
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- CPP
- Future
- Unreal
- async
- Modern
- 포인터
- MOVE
- std::move
- Effective
- 보편 참조
- Forwarding
- Effective Modern C++
- 발아시기
- Overloading
- 다이소
- const
- Perfect
- auto
- C++
- 보편참조
- std::forward
- detach
- C
- 람다
- C++14
- Join
- forward
- Override
- thread
- C++11
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함