18
Effective Modern C++ Study C++ Korea

[C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Embed Size (px)

Citation preview

Page 1: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea

Page 2: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건
Page 3: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea3

Page 4: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건
Page 5: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea5

Page 6: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea6

auto templatedirect mapping

type deducing type deducing

Page 7: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea7

template : expr을이용해 ParamType과 T를타입추론한다.

auto : auto가템플릿에서 T의역할을 , 형식지정자(type specifier)가ParamType의역할을한다.같은방식으로 타입추론한다.

auto param = expr;

Page 8: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea8

conceptional templatetemplate<typename T>

void func_for_x(T param);

func_for_x(27);

template<typename T>

void func_for_cx(const T param);

func_for_cx(27);

template<typename T>

void func_for_rx(const T& param);

func_for_rx(27);

auto로변수 선언auto x = 27;

const auto cx = x;

const auto & rx = x;

Page 9: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea9

conceptional templatetemplate<typename T>

void func_for_x(T param);

func_for_x(27);

auto로변수 선언auto x = 27;

컴파일러가하는 일auto로변수를선언 -> 각각맞는템플릿을호출 ->

템플릿타입추론 -> 추론한 형식에맞는 initializing expression 호출

Page 10: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea10

Page 11: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea11

Page 12: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea12

Page 13: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea13

Page 14: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea14

Page 15: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea15

Page 16: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea16

Page 17: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea17

Page 18: [C++ korea] effective modern c++ study item 2 understanding auto type deduction +손건

Effective Modern C++ StudyC++ Korea18