[C++ Korea] Effective Modern C++ Study item14 16 +신촌Seok-joon Yun
[C++ Korea] Effective Modern C++ Study item14 16 +신촌
Item 14 : Declare functions noexcept if they won't emit exceptions. +윤석준
Item 15 : Use constexpr whenever possible. +이동우
Item 16 : Make const member functions thread safe. +제한재
[C++ Korea] Effective Modern C++ Study item 24-26Seok-joon Yun
[C++ Korea] Effective Modern C++ Study item 24-26
Item 24: Distinguish universal references from rvalue references. +석정로
Item 25 : Use std::move on rvalue references,
std::forward on universal references. +서승덕
Item 26 : Avoid overloading on universal references. +윤석준
[C++ Korea] Effective Modern C++ Study item14 16 +신촌Seok-joon Yun
[C++ Korea] Effective Modern C++ Study item14 16 +신촌
Item 14 : Declare functions noexcept if they won't emit exceptions. +윤석준
Item 15 : Use constexpr whenever possible. +이동우
Item 16 : Make const member functions thread safe. +제한재
[C++ Korea] Effective Modern C++ Study item 24-26Seok-joon Yun
[C++ Korea] Effective Modern C++ Study item 24-26
Item 24: Distinguish universal references from rvalue references. +석정로
Item 25 : Use std::move on rvalue references,
std::forward on universal references. +서승덕
Item 26 : Avoid overloading on universal references. +윤석준
[C++ Korea] Effective Modern C++ Sinchon Study Item 37-39Seok-joon Yun
The document discusses effective study of modern C++. It covers topics like constexpr for defining constants, futures and promises for asynchronous programming, shared futures for sharing future states between objects, and packaged tasks for launching functions asynchronously using threads. Examples are provided for defining constants with constexpr, getting futures from promises, storing futures in vectors and classes, and using packaged tasks to launch tasks on threads.
[C++ Korea] Effective Modern C++ Sinchon Study Item 37-39Seok-joon Yun
The document discusses effective study of modern C++. It covers topics like constexpr for defining constants, futures and promises for asynchronous programming, shared futures for sharing future states between objects, and packaged tasks for launching functions asynchronously using threads. Examples are provided for defining constants with constexpr, getting futures from promises, storing futures in vectors and classes, and using packaged tasks to launch tasks on threads.
[C++ Korea 2nd Seminar] C++17 Key Features SummaryChris Ohk
C++은 10년 만에 C++11/14를 발표하면서 '모던 C++'이라는 이름으로 발전했습니다. 그만큼 새로운 기능들이 많이 추가되었습니다. 그리고 2017년, C++은 C++17이라는 이름으로 또 한 번의 발전을 준비하고 있습니다. 3년 주기로 빠르게 변화하는 모던 C++에 대비하기 위해, C++17에 추가될 주요 기능들을 살펴보고자 합니다.
1. Effective Modern C++ Study
C++ Korea
C++ Korea
Effective Modern C++ Study
Item 1 – 3
Item 1 : Understand template type deduction.
Item 2 : Understand auto type deduction.
Item 3 : Understand decltype.
3. Effective Modern C++ Study
C++ Korea
Deducing Types
C++ 11에서의 auto는 template 기반으로 한다.
떄문에 템플릿에 적용할 떄보다 덜 직관적으로
보인다
템플릿에는 추론 방법이 3가지가 있다.
3
4. Effective Modern C++ Study
C++ Korea
Deducing Types
컴파일을 하는 동안 컴파일러는 T및 paramType
두 타입을 추론하기 위해 expr 을 사용합니다.
4
5. Effective Modern C++ Study
C++ Korea
Case 1: ParamType 이 참조, 포인터인 경우
Case 2: ParamType 가 Universal Reference 경우
Case 3: ParamType 가 참조 또는 포인터가
아닐떄
5
6. Effective Modern C++ Study
C++ Korea
Case 1
ParamType 이 참조거나 포인터인 경우
1)expr 타입이 참조 타입일떄 참조 부분은
무시됩니다.
2)expr 타입과 매치한 후 paramtype으로 T를
결정합니다
6
7. Effective Modern C++ Study
C++ Korea
Case 1
void f(T& param); // param is a reference
int x = 27;
const int cx = x;
const int& rx = x;
F(x); // param int&
F(cx); //param's type is const int&
F(rx); //param's type is const int&
7
8. Effective Modern C++ Study
C++ Korea
Case 1
template<typename T>
void f(T* param);
int x = 27;
const int *px = &x
f(&x); // param's type is int*
f(px); //param's type is const int*
8
9. Effective Modern C++ Study
C++ Korea
Case 2:
ParamType 가 Universal Reference 경우
1.If expr is an lvalue
1) T와 paramtype은 lvalue 의해 추론.
2) 비록 paramtype이 rvalue 선언되어있어도 참조lvalue 로 참조
2.expr이 rvalue 일떄 case 1가 동일하게 적용
9
10. Effective Modern C++ Study
C++ Korea
Case 2:
void f(T&& param);
int x = 27;
const int cx = x;
const int& rx = x;
F(x); F(cx);
F(rx); F(27);
10
11. Effective Modern C++ Study
C++ Korea
Case 3:
Case 3: ParamType 가 참조,포인터가 아닐떄
expr이 reference ,const,volatile 다 무시됩니다.
11
12. Effective Modern C++ Study
C++ Korea
Case 3:
void f(T param);
int x = 27;
const int cx = x;
const int& rx = x;
f(x); // T's and param's types are both int
f(cx); // T's and param's types are both int
f(rx); // T's and param's types are both int
12
13. Effective Modern C++ Study
C++ Korea
정리
템플릿 타입 추론을 하는동안. 레퍼런스 타입의
인수들은 레퍼런스가 아닌 타입으로 취급
유니버셜 레버런스에 대한 타입 추론을 할떄 Lvalue
인수들은 특별한 취급을 받게됨
템플릿 타입 추론을 하는동안 포인터를 사용하는
인수들은 초기화할떄 레퍼런스 타입을 사용하지 않으면
포인터 붕괴가 일어남
13