ݺߣ

ݺߣShare a Scribd company logo
Effective Modern C++ Study
C++ Korea
Speaker : Yun Seok-joon ( icysword77@gmail.com )
Prefer alias declarations to typedefs.
1. C++98 typedef , #define
2. C++11 using (alias declaration)
3. alias template
4. Type Trait Transformation
1. C++98 typedef, #define
Effective Modern C++ Study
C++ Korea
#define INT32 int
typedef unsigned char BYTE;
typedef unsigned short WORD;
5
#define 은 단순 문자열 치환기능 -> Debugging 힘듬
typedef 는 원래 타입을 숨김 -> 코드 이해도 하락
Effective Modern C++ Study
C++ Korea
int nVal1 = 2;
int nVal2 = 3;
void FUNC_SKY(int args) { std::cout << "Sky : " << args << std::endl; }
void FUNC_FLY(int args) { std::cout << "Fly : " << args << std::endl; }
#define MAC_FUNC(F, N) FUNC_##F(nVal##N)
MAC_FUNC(SKY, 2); // Sky : 3
6
## : 앞뒤 문자들을 붙여서 Code에 삽입
Effective Modern C++ Study
C++ Korea
typedef basic_string<char, char_traits<char>, allocator<char>> string;
7
어떤게 더 편할까요 ?
std::string strA;
std::string strB;
std::basic_string<char, char_traits<char>, allocator<char>> strA;
std::basic_string<char, char_traits<char>, allocator<char>> strB;
const std::_Simple_types<std::_Wrap_alloc<std::_Vec_base_types<Widget,
std::allocator<Widget> >::_Alloc>::value_type>::value_type *
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to typedefs +윤석준
Effective Modern C++ Study
C++ Korea9
// C++98 typedef
typedef std::unique_ptr<std::unordered_map<std::string, std::string>> UPM_SS;
// C++11 using
using UPM_SS = std::unique_ptr<std::unordered_map<std::string, std::string>>;
에이~ 별 차이 없자나.
Effective Modern C++ Study
C++ Korea10
// C++98 typedef
typedef void(*Func)(int, const std::string&);
// using (alias declaration)
using Func = void(*)(int, const std::string&);
좀 보기 좋긴 한데…
그래도~ 별 차이 없자나.
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to typedefs +윤석준
Effective Modern C++ Study
C++ Korea12
template<typename T> // using (alias declaration)
using MyList = std::list<T, MyAlloc<T>>;
template<typename T> // typedef
struct MyList
{
typedef std::list<T, MyAlloc<T>> TYPE;
};
MyList<Widget> LW;
MyList<Widget>::TYPE LW;
선언이 좀 불편하긴 하네.
근데 사용은 더 불편하다.
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to typedefs +윤석준
Effective Modern C++ Study
C++ Korea14
template 타입의 속성을 변화
std::remove_const<T>::type // T from const T
std::remove_reference<T>::type // T from T&, T&&
std::add_lvalue_reference<T>::type // T& from T
::type ?
누가봐도 template struct typedef 사용한것임을 알수 있다.
Effective Modern C++ Study
C++ Korea15
std::remove_const_t<T> // T from const T
std::remove_reference_t<T> // T from T&, T&&
std::add_lvalue_reference_t<T> // T& from T
이름이 중복 되니깐 _t를 붙여서 사용
Effective Modern C++ Study
C++ Korea16
template<class T>
using remove_const_t = typename std::remove_const<T>::type;
template<class T>
using remove_refernece_t = typename std::remove_reference_t<T>::type;
template<class T>
using add_lvalue_reference_t
= typename std::add_lvalue_reference<T>::type;
Effective Modern C++ Study
C++ Korea17
http://www.cplusplus.com/reference/type_traits
…
[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to typedefs +윤석준
Effective Modern C++ Study
C++ Korea19
• using (별칭선언)은 template를 지원합니다.
• using은 ::type 을 뒤에 붙일 필요도 없고,
typename 을 앞에 붙일 필요도 없습니다.
• C++14에서는 C++11의 Type Trait Transformation을
별칭 선언으로 지원합니다.
http://devluna.blogspot.kr/2015/03/item-9-typedef.html
icysword77@gmail.com

More Related Content

What's hot (20)

[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
Seok-joon Yun
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26
Seok-joon Yun
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
Chris Ohk
[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study
Seok-joon Yun
C++ 타입 추론
C++ 타입 추론C++ 타입 추론
C++ 타입 추론
Huey Park
C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2
Chris Ohk
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
Seok-joon Yun
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Chris Ohk
Visual studio 2010
Visual studio 2010Visual studio 2010
Visual studio 2010
MinGeun Park
2013 C++ Study For Students #1
2013 C++ Study For Students #12013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심
흥배 최
C++20 Key Features Summary
C++20 Key Features SummaryC++20 Key Features Summary
C++20 Key Features Summary
Chris Ohk
C++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsC++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threads
Seok-joon Yun
Changes in c++0x
Changes in c++0xChanges in c++0x
Changes in c++0x
4002 JOF
C++11
C++11C++11
C++11
선협 이
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
Chris Ohk
C++11
C++11C++11
C++11
Yubin Lim
프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기
Jongwook Choi
[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성
MinGeun Park
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
[C++ korea] Effective Modern C++ 신촌 Study Item20,21,23
Seok-joon Yun
[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26[C++ Korea] Effective Modern C++ Study item 24-26
[C++ Korea] Effective Modern C++ Study item 24-26
Seok-joon Yun
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3[C++ Korea] Effective Modern C++ Study, Item 1 - 3
[C++ Korea] Effective Modern C++ Study, Item 1 - 3
Chris Ohk
[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study[C++ korea] effective modern c++ study item 17 19 신촌 study
[C++ korea] effective modern c++ study item 17 19 신촌 study
Seok-joon Yun
C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2C++17 Key Features Summary - Ver 2
C++17 Key Features Summary - Ver 2
Chris Ohk
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...[C++ korea] effective modern c++ study   item 2 understanding auto type deduc...
[C++ korea] effective modern c++ study item 2 understanding auto type deduc...
Seok-joon Yun
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기
Chris Ohk
2013 C++ Study For Students #1
2013 C++ Study For Students #12013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary[C++ Korea 2nd Seminar] C++17 Key Features Summary
[C++ Korea 2nd Seminar] C++17 Key Features Summary
Chris Ohk
Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심Modern C++ 프로그래머를 위한 CPP11/14 핵심
Modern C++ 프로그래머를 위한 CPP11/14 핵심
흥배 최
C++20 Key Features Summary
C++20 Key Features SummaryC++20 Key Features Summary
C++20 Key Features Summary
Chris Ohk
C++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threadsC++ Concurrency in Action 9-2 Interrupting threads
C++ Concurrency in Action 9-2 Interrupting threads
Seok-joon Yun
Changes in c++0x
Changes in c++0xChanges in c++0x
Changes in c++0x
4002 JOF
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
[C++ Korea 3rd Seminar] 새 C++은 새 Visual Studio에, 좌충우돌 마이그레이션 이야기
Chris Ohk
프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기프로그래밍 대회: C++11 이야기
프로그래밍 대회: C++11 이야기
Jongwook Choi
[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성[Pl in c++] 9. 다형성
[Pl in c++] 9. 다형성
MinGeun Park

Similar to [C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to typedefs +윤석준 (20)

Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉
HyunJoon Park
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
tcaesvk
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
명신 김
Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료
Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료
Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료
SeongTae Jeong
모던 C++ 정리
모던 C++ 정리모던 C++ 정리
모던 C++ 정리
Hansol Kang
C++ 프로그래밍 2014-2018년 기말시험 기출문제
C++ 프로그래밍 2014-2018년 기말시험 기출문제C++ 프로그래밍 2014-2018년 기말시험 기출문제
C++ 프로그래밍 2014-2018년 기말시험 기출문제
Lee Sang-Ho
[C++ Korea] Effective Modern C++ Study item 31-33
[C++ Korea] Effective Modern C++ Study item 31-33[C++ Korea] Effective Modern C++ Study item 31-33
[C++ Korea] Effective Modern C++ Study item 31-33
Seok-joon Yun
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기
Sang Heon Lee
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
Sang Don Kim
포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++
KWANGIL KIM
[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli
종빈 오
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부
Gwangwhi Mah
델파이 코딩 스타일과 아키텍처
델파이 코딩 스타일과 아키텍처델파이 코딩 스타일과 아키텍처
델파이 코딩 스타일과 아키텍처
Devgear
Ai C#세미나
Ai C#세미나Ai C#세미나
Ai C#세미나
Astin Choi
Agd Test Driven Development For Games What, Why, And How)(Game Connect 2006...
Agd   Test Driven Development For Games What, Why, And How)(Game Connect 2006...Agd   Test Driven Development For Games What, Why, And How)(Game Connect 2006...
Agd Test Driven Development For Games What, Why, And How)(Game Connect 2006...
Ryan Park
이산수학 C1 프로젝트 7
이산수학 C1 프로젝트 7이산수학 C1 프로젝트 7
이산수학 C1 프로젝트 7
pkok15
Ds4 artist week_05
Ds4 artist week_05Ds4 artist week_05
Ds4 artist week_05
SeungBum Kim
Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉Modern C++의 타입 추론과 람다, 컨셉
Modern C++의 타입 추론과 람다, 컨셉
HyunJoon Park
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
NDC 2011, 네트워크 비동기 통신, 합의점의 길목에서
tcaesvk
불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14 불어오는 변화의 바람, From c++98 to c++11, 14
불어오는 변화의 바람, From c++98 to c++11, 14
명신 김
Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료
Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료
Tech-days 미니 토요세미나 - 3회 C#편 PPT 자료
SeongTae Jeong
C++ 프로그래밍 2014-2018년 기말시험 기출문제
C++ 프로그래밍 2014-2018년 기말시험 기출문제C++ 프로그래밍 2014-2018년 기말시험 기출문제
C++ 프로그래밍 2014-2018년 기말시험 기출문제
Lee Sang-Ho
[C++ Korea] Effective Modern C++ Study item 31-33
[C++ Korea] Effective Modern C++ Study item 31-33[C++ Korea] Effective Modern C++ Study item 31-33
[C++ Korea] Effective Modern C++ Study item 31-33
Seok-joon Yun
[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기[NDC2016] TERA 서버의 Modern C++ 활용기
[NDC2016] TERA 서버의 Modern C++ 활용기
Sang Heon Lee
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
[Td 2015]녹슨 c++ 코드에 모던 c++로 기름칠하기(옥찬호)
Sang Don Kim
포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++
KWANGIL KIM
[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli[shaderx6]8.2 3d engine tools with c++cli
[shaderx6]8.2 3d engine tools with c++cli
종빈 오
C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부C++ 11 에 대해서 쉽게 알아봅시다 1부
C++ 11 에 대해서 쉽게 알아봅시다 1부
Gwangwhi Mah
델파이 코딩 스타일과 아키텍처
델파이 코딩 스타일과 아키텍처델파이 코딩 스타일과 아키텍처
델파이 코딩 스타일과 아키텍처
Devgear
Agd Test Driven Development For Games What, Why, And How)(Game Connect 2006...
Agd   Test Driven Development For Games What, Why, And How)(Game Connect 2006...Agd   Test Driven Development For Games What, Why, And How)(Game Connect 2006...
Agd Test Driven Development For Games What, Why, And How)(Game Connect 2006...
Ryan Park
이산수학 C1 프로젝트 7
이산수학 C1 프로젝트 7이산수학 C1 프로젝트 7
이산수학 C1 프로젝트 7
pkok15

More from Seok-joon Yun (20)

Retrospective.2020 03
Retrospective.2020 03Retrospective.2020 03
Retrospective.2020 03
Seok-joon Yun
Sprint & Jira
Sprint & JiraSprint & Jira
Sprint & Jira
Seok-joon Yun
Eks.introduce.v2
Eks.introduce.v2Eks.introduce.v2
Eks.introduce.v2
Seok-joon Yun
Eks.introduce
Eks.introduceEks.introduce
Eks.introduce
Seok-joon Yun
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image ConverterAWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
Seok-joon Yun
아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지
Seok-joon Yun
Pro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, PerformancePro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, Performance
Seok-joon Yun
Doing math with python.ch07
Doing math with python.ch07Doing math with python.ch07
Doing math with python.ch07
Seok-joon Yun
Doing math with python.ch06
Doing math with python.ch06Doing math with python.ch06
Doing math with python.ch06
Seok-joon Yun
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05
Seok-joon Yun
Doing math with python.ch04
Doing math with python.ch04Doing math with python.ch04
Doing math with python.ch04
Seok-joon Yun
Doing math with python.ch03
Doing math with python.ch03Doing math with python.ch03
Doing math with python.ch03
Seok-joon Yun
Doing mathwithpython.ch02
Doing mathwithpython.ch02Doing mathwithpython.ch02
Doing mathwithpython.ch02
Seok-joon Yun
Doing math with python.ch01
Doing math with python.ch01Doing math with python.ch01
Doing math with python.ch01
Seok-joon Yun
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
Seok-joon Yun
Welcome to Modern C++
Welcome to Modern C++Welcome to Modern C++
Welcome to Modern C++
Seok-joon Yun
[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2
Seok-joon Yun
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
Seok-joon Yun
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
Seok-joon Yun
오렌지6.0 교육자료
오렌지6.0 교육자료오렌지6.0 교육자료
오렌지6.0 교육자료
Seok-joon Yun
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image ConverterAWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
AWS DEV DAY SEOUL 2017 Buliding Serverless Web App - 직방 Image Converter
Seok-joon Yun
아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지아파트 시세,어쩌다 머신러닝까지
아파트 시세,어쩌다 머신러닝까지
Seok-joon Yun
Pro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, PerformancePro typescript.ch07.Exception, Memory, Performance
Pro typescript.ch07.Exception, Memory, Performance
Seok-joon Yun
Doing math with python.ch07
Doing math with python.ch07Doing math with python.ch07
Doing math with python.ch07
Seok-joon Yun
Doing math with python.ch06
Doing math with python.ch06Doing math with python.ch06
Doing math with python.ch06
Seok-joon Yun
Doing math with python.ch05
Doing math with python.ch05Doing math with python.ch05
Doing math with python.ch05
Seok-joon Yun
Doing math with python.ch04
Doing math with python.ch04Doing math with python.ch04
Doing math with python.ch04
Seok-joon Yun
Doing math with python.ch03
Doing math with python.ch03Doing math with python.ch03
Doing math with python.ch03
Seok-joon Yun
Doing math with python.ch01
Doing math with python.ch01Doing math with python.ch01
Doing math with python.ch01
Seok-joon Yun
Pro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScriptPro typescript.ch03.Object Orientation in TypeScript
Pro typescript.ch03.Object Orientation in TypeScript
Seok-joon Yun
[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2[2015-07-20-윤석준] Oracle 성능 관리 2
[2015-07-20-윤석준] Oracle 성능 관리 2
Seok-joon Yun
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
[2015-07-10-윤석준] Oracle 성능 관리 & v$sysstat
Seok-joon Yun
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
[2015 07-06-윤석준] Oracle 성능 최적화 및 품질 고도화 4
Seok-joon Yun

[C++ Korea] Effective Modern C++ MVA item 9 Prefer alias declarations to typedefs +윤석준

  • 1. Effective Modern C++ Study C++ Korea Speaker : Yun Seok-joon ( icysword77@gmail.com )
  • 3. 1. C++98 typedef , #define 2. C++11 using (alias declaration) 3. alias template 4. Type Trait Transformation
  • 5. Effective Modern C++ Study C++ Korea #define INT32 int typedef unsigned char BYTE; typedef unsigned short WORD; 5 #define 은 단순 문자열 치환기능 -> Debugging 힘듬 typedef 는 원래 타입을 숨김 -> 코드 이해도 하락
  • 6. Effective Modern C++ Study C++ Korea int nVal1 = 2; int nVal2 = 3; void FUNC_SKY(int args) { std::cout << "Sky : " << args << std::endl; } void FUNC_FLY(int args) { std::cout << "Fly : " << args << std::endl; } #define MAC_FUNC(F, N) FUNC_##F(nVal##N) MAC_FUNC(SKY, 2); // Sky : 3 6 ## : 앞뒤 문자들을 붙여서 Code에 삽입
  • 7. Effective Modern C++ Study C++ Korea typedef basic_string<char, char_traits<char>, allocator<char>> string; 7 어떤게 더 편할까요 ? std::string strA; std::string strB; std::basic_string<char, char_traits<char>, allocator<char>> strA; std::basic_string<char, char_traits<char>, allocator<char>> strB; const std::_Simple_types<std::_Wrap_alloc<std::_Vec_base_types<Widget, std::allocator<Widget> >::_Alloc>::value_type>::value_type *
  • 9. Effective Modern C++ Study C++ Korea9 // C++98 typedef typedef std::unique_ptr<std::unordered_map<std::string, std::string>> UPM_SS; // C++11 using using UPM_SS = std::unique_ptr<std::unordered_map<std::string, std::string>>; 에이~ 별 차이 없자나.
  • 10. Effective Modern C++ Study C++ Korea10 // C++98 typedef typedef void(*Func)(int, const std::string&); // using (alias declaration) using Func = void(*)(int, const std::string&); 좀 보기 좋긴 한데… 그래도~ 별 차이 없자나.
  • 12. Effective Modern C++ Study C++ Korea12 template<typename T> // using (alias declaration) using MyList = std::list<T, MyAlloc<T>>; template<typename T> // typedef struct MyList { typedef std::list<T, MyAlloc<T>> TYPE; }; MyList<Widget> LW; MyList<Widget>::TYPE LW; 선언이 좀 불편하긴 하네. 근데 사용은 더 불편하다.
  • 14. Effective Modern C++ Study C++ Korea14 template 타입의 속성을 변화 std::remove_const<T>::type // T from const T std::remove_reference<T>::type // T from T&, T&& std::add_lvalue_reference<T>::type // T& from T ::type ? 누가봐도 template struct typedef 사용한것임을 알수 있다.
  • 15. Effective Modern C++ Study C++ Korea15 std::remove_const_t<T> // T from const T std::remove_reference_t<T> // T from T&, T&& std::add_lvalue_reference_t<T> // T& from T 이름이 중복 되니깐 _t를 붙여서 사용
  • 16. Effective Modern C++ Study C++ Korea16 template<class T> using remove_const_t = typename std::remove_const<T>::type; template<class T> using remove_refernece_t = typename std::remove_reference_t<T>::type; template<class T> using add_lvalue_reference_t = typename std::add_lvalue_reference<T>::type;
  • 17. Effective Modern C++ Study C++ Korea17 http://www.cplusplus.com/reference/type_traits …
  • 19. Effective Modern C++ Study C++ Korea19 • using (별칭선언)은 template를 지원합니다. • using은 ::type 을 뒤에 붙일 필요도 없고, typename 을 앞에 붙일 필요도 없습니다. • C++14에서는 C++11의 Type Trait Transformation을 별칭 선언으로 지원합니다. http://devluna.blogspot.kr/2015/03/item-9-typedef.html icysword77@gmail.com