본문 바로가기
Script/Modern C++

[Modern C++] Chapter 04. using

by song.ift 2023. 5. 22.

GitHub : https://github.com/developeSHG/Modern-C/blob/a30dc0a22e2afcdb8ae81e9ca9e3f46fb125ab66/Modern%20C%2B%2B/Modern%20C%2B%2B/using.cpp

 

GitHub - developeSHG/Modern-C: Modern C++

Modern C++. Contribute to developeSHG/Modern-C development by creating an account on GitHub.

github.com

 

 


 

 

cpp
닫기
// 주제 : using typedef vector<int>::iterator VecIt; typedef __int64 id; using id2 = int; // 1) 직관성 // 예시. 함수포인터 typedef void (*MyFunc)(); using MyFunc2 = void(*)(); // 2) 템플릿 template<typename T> typedef std::list<T> List; // 형식이 맞지않아 사용이 불가능. template<typename T> using List = std::list<T>; // 그럼 C++11 이전에 typedef으로 어떻게 사용헀느냐? // 간접적으로 활용해서 사용했다. template<typename T> struct List2 { typedef std::list<T> type; } int main() { ‌List<int> li; ​​​​li.push_back(1); ​​​​li.push_back(2); ​​​​ ​​​​List2<int>::type li2; // 매우 불편.. ​​​​ ​​​​return 0; }

'Script > Modern C++' 카테고리의 다른 글

[Modern C++] Chapter 06. delete  (0) 2023.05.22
[Modern C++] Chapter 05. enum class  (0) 2023.05.22
[Modern C++] Chapter 03. nullptr  (0) 2023.05.22
[Modern C++] Chapter 02. 중괄호 초기화 { }  (0) 2023.05.22
[Modern C++] Chapter 01. auto  (0) 2023.05.22

댓글