![(c++) ํจ์ ๋ค const](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbtqi1G%2FbtsIff1jDPn%2Fa40cQSrPkYchE8DjomWBl0%2Fimg.png)
" ํจ์ ๋ค const " class Test { public: void ResizeVector(int num) const { vec.resize(num); } private: vector vec;} ์์ ์๋ ํจ์๋ ์ปดํ์ผ์ด ๋ ๊น? ์ ๋ต์ ์๋๋ค. ์ด์ ๋ ํจ์ ๋ค const ๋๋ฌธ์ vector ๋ด์ฅํจ์์ธ resize๋ฅผ ์ฌ์ฉํ ์ ์๋ค.ํจ์ const์ ๋ํด์ ๊ฐ๋จํ๊ฒ ์์๋ณด์. [ ์๋ฏธ ] - ํด๋น ํจ์์์๋ ํด๋น ๊ฐ์ฒด์ ๋ฉค๋ฒ๋ณ์๋ฅผ ๋ณ๊ฒฝํ ์ ์๋ค. - ์ฌ๊ธฐ์ ์ด๋ฒ์ ์๋ก ์๊ฒ ๋ ์ฌ์ค์ ๋ฉค๋ฒ๋ณ์์ ์์ฐจ ์ปจํ ์ด๋ vector๊ฐ ์์๋๋ฐ vector ๋ด์ฅ ํจ์๋ ์ ํ ๋ฐ๋๋ค๋ ๊ฒ์ด๋ค.์ด์ฐ๋ณด๋ฉด ๋น์ฐํ๊ฑฐ์ง๋ง ...? ์ปดํ์ผ ์ ์ ์ค๋ฅ๋ฉ์์ง๋ฅผ ๋ฑ๋๊ฒ ์ ๊ธฐํ๋ค...
![(c++20) STL::Container #2 - contains, starts_with, ends_with](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FcFPxiM%2FbtsIe3MzKr4%2F7fDHkJ6RoZXAs8JWBQwfHK%2Fimg.png)
"c++20 STL::Container #2" 1. contains๊ธฐ์กด map, set ๋ฐ์ดํฐ findํจ์ ์ฌ์ฉ ์ ๋ฐ๋ณต์์ end๋ฐ๋ณต์๊ฐ ๊ฐ์ง ์์ ์ง ๋น๊ตํ๋ ๋ฐฉ์์ด์๋ค. std::set s {1, 2, 3, 4, 5}; auto findset = s.find(2);if (findset != s.end()){ cout m {{1, 1000}, { 2, 2000 }}; auto findmap = m.find(2); if(findmap != m.end()){ cout second c++20์์ ์๋ก ์ถ๊ฐ ๋ contains๋ associate container์ ๋ด์ฅํจ์๋ก ์ฐพ์ผ๋ ค๋ ํค๊ฐ์ ๋ฃ์ผ๋ฉด true, false๋ก ๊ทธ key์ ์กด์ฌ ์ฌ๋ถ๋ฅผ ์ ์ ์๋ค. if (findset.contains(2)..
![(c++20) STL::Container #1 - std::to_array, erase, erase_if](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FoQKcp%2FbtsIcxoPyhz%2FoZsKPFXUcH0Ntd1M2UcnEK%2Fimg.png)
"c++20 STL::Container #1" 1. std::to_array std::array ๋ง๋๋ ๋ฐฉ๋ฒ์ด ์ถ๊ฐ๋์๋ค. //์์์ ํ์ ์ถ๋ก auto ToArray = std::to_array("Hello World");//๋ช ์์ ํ์ ์ถ๋ก auto ToArray = std::to_array({ 1,2,3,4,5,6 }); 2. std::erase, erase_if ๊ธฐ์กด์ vector ๋ฐ์ดํฐ ์ค ํน์ ํ ์กฐ๊ฑด์ ๋ถํฉํ๋ ๋ฐ์ดํฐ๋ฅผ ์ญ์ ํ๋ ค๊ณ ํ ๋ ์ฌ๋ฌ๊ฐ์ง ๋ฐฉ๋ฒ๊ณผ ๋ฌธ์ ์ ์ ์์๋ณด์.// 1๋ฒ ====================================================================vector vec {-1, 2, 3, 4, -5, 7, -2, 3 }; for (auto i..
![(c++20) Conditional Explicit Constructor](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F8yrlH%2FbtsIde26Eg7%2FKkbTpHcoCiXMYB55BriLrk%2Fimg.png)
"(c++20) Conditional Explicit Constructor" 1. explicit // c++11 struct NoExplicit{ NoExplicit() = default; NoExplicit(int n) { cout TestNoExplicit(10); // - ???? error X TestNoExplicit() NoExplicit struct ์๋ฃํ์ ๋งค๊ฐ๋ณ์๋ก ๋ฐ๊ณ ์๋ค. ๊ทธ๋ผ ๋งค๊ฐ๋ณ์์ NoExplicit struct ์ด ์ธ์ ๋ค๋ฅธ ์๋ฃํ์ด ๋ค์ด๊ฐ๋ค๋ฉด ์๋ฌ๋ฅผ ๋ฑ์ด๋ด๋๊ฒ ์ ์์ด๋ค. ํ์ง๋ง ์ ์ฝ๋์์ TestNoExplicit(10) ์๋ฌ๋ฅผ ๋ฑ์ด ๋ผ๊ฑฐ ๊ฐ์ง๋ง ์ ์ ์๋ํ๋ค. ์ด๋ ์ปดํ์ผ๋ฌ์์ "10"์ NoExplicit(int n)" ์์ฑ์๋ฅผ ์ด์ฉํ์ฌ ์์์ ํ๋ณํ์ ..
![(c++20) [Three-way Comparsion(3๋ฐฉํฅ ๋น๊ต ์ฐ์ฐ์)/์ฐ์ฃผ์ ] ์ฐ์ฐ์](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FlbkUC%2FbtsIdzlGy41%2FZoYcnXXQuigohei3aLGWI1%2Fimg.png)
"(c++20) Three-way Comparsion(3๋ฐฉํฅ ๋น๊ต ์ฐ์ฐ์)/์ฐ์ฃผ์ " c++20์ ์ถ๊ฐ๋ ๊ฒ ์ค์ ์์ฃผ ํธ์ํ ์ฐ์ฐ์ ์ค๋ฒ๋ก๋ฉ์ด ์๊ฒผ๋ค. !! ์ง๊ธ์ ์๋๋๋ผ๋(?) ์์ฃผ ์ ์ฉํ๊ฒ ์ฐ์ผ ๊ฑฐ ๊ฐ์ ๋ ์์ด๋ผ์ ์ ๋ฆฌํด๋ณธ๋ค. class๋ struct๋ฅผ ๋ง๋ค์ด์ ๊ทธ ๊ฐ์ฒด๋ผ๋ฆฌ ๋น๊ต๋ฅผ ํ๊ธฐ ์ํด์๋ ํ์์ ๋ฐ๋ผ [ '' '>=' '==' '!=' : 6๊ฐ] ์ฐ์ฐ์ ์ค๋ฒ๋ก๋ฉ์ ํด์ผํ๋ค. ํ์ง๋ง ์ฌ๊ธฐ์ c++20์ ์ถ๊ฐ๋ Three-way Comparsion ์ฐ์ฐ์๋ฅผ ์ฌ์ฉํ๋ฉด 6๊ฐ๋ฅผ ํฌํจํ operatorํ๋๋ง ์ ์ํ๋ฉด ๋๋ค. #include using namespace std;struct Myoperator{ Myoperator(int value) : _value(value) { } //auto ope..
![(c++20) consteval, constinit](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fb1hxFb%2FbtsIe2GTvCH%2Futzt1bi9xGk0VvnBLuWbW1%2Fimg.png)
"(c++20) consteval, constinit" C++20์ ์ถ๊ฐ๋ Language ์ค consteval, constinit์ ๋ํด์ ์์๋ณด๊ณ ๊ธฐ์กด์ ์์๋ const์ constexpr๊ณผ ๋น๊ตํด๋ณด๋ ค๊ณ ํ๋ค. ์ผ๋จ ์ด๋ค ๋จ์ด์ ์ค์๋ง์ธ์ง ํ์ธํ๊ณ ๋์ด๊ฐ์ ~const: Constant ์์constexpr: Constant Expression ํํ// c++11consteval: Constant Evaluation ๊ฒ์ฆ // c++20 constinit: Constrant Initialization ์ด๊ธฐํ // c++20ํจ์์ ํค์ํธ๋ฅผ ๋ถ์์ ๋, ๋ณ์์ ํค์๋๋ฅผ ๋ถ์์ ๋๋ฅผ ๋๋ ์ ์ ๋ฆฌํด๋ณด์๋ค. 1. ํจ์ (์ผ๋ฐ vs constexpr vs consteval) ๋จผ์ ์ ํํด์ผ ํ ๊ฐ๋ ์ ๋ฐํ์(..
![[c++17] ์ ๋ฌธ์๋ฅผ ์ํ c++17 ์๋ก์ด ๋ด์ฉ ๋ถ๋งํฌ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbH3lZX%2FbtsFGqxSJAh%2FmKEe7KW0X9rn98ZGVXISNK%2Fimg.png)
c++17์ ์ถ๊ฐ๋ ๋ฌธ๋ฒ์ ๋์ "์ ๋ฌธ๊ฐ๋ฅผ ์ํ C++17(๊ฐ์ 4ํ)"์์ ๋น ๋ฅด๊ฒ ์ฐพ๊ธฐ ์ํด์ ์ ๋ฆฌํด๋ณด์๋ค. page 58์ค์ฒฉ๋ ๋ค์์คํ์ด์ค (nested namespace)61std::byte69if๋ฌธ์ ์ด๋์ ๋ผ์ด์ (intializer : ์ด๊ธฐ์)72switch๋ฌธ์ ์ด๋์ ๋ผ์ด์ (intializer : ์ด๊ธฐ์)81๊ตฌ์กฐ์ ๋ฐ์ธ๋ฉ(structured binding)138๋ก์ฐ ๋ ๋ฒจ ์ซ์ ๋ณํ "}">#include 140std::string_viewํด๋์ค298weak_ptr๋ shared_ptr์ ๋ง์ฐฌ๊ฐ์ง๋ก C์คํ์ผ ๋ฐฐ์ด์ ์ง์ํ๋ค.299weak_from_this()390static ๋ฐ์ดํฐ ๋ฉค๋ฒ๋ฅผ inline์ผ๋ก ์ ์ธํ ์ ์๋ค.530std::as_const() ํฌํผ ๋ฉ์๋ "}">#include (obj)..
![[C++] Map์ Key๋ก Class/Struct ๋ฃ๊ธฐ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdkBZMZ%2FbtsBGUxcfrd%2FAFwaBlIb4QavgYsvkqXvT0%2Fimg.png)
์ค๋์ "ํธ๋ญ์ด์์ธ๊ต" ๋ณ์๋ฆฌ ๋ธ๋ก๊ทธ๋ฅผ ์ด์ํ๋ ๊น๋์ค๋์ ํฌ์คํ ์ ํ์ณ์๋ค !! ๋๊ฐ์ด ํฌ์คํ ํด๋ ๋๋ค๊ณ ํ๋ฝ์ ๋ฐ์๊ธฐ ๋๋ฌธ์ ์ถ์ฒ๋ฅผ ๋ฐํ๊ณ ๊ฑฐ์ 80% ๊ฐ์ ๋ด์ฉ์ ํฌ์คํ ํ๋ค. ๊ณ ๋ง์์ ๊น๋์ค๋ ~ ** Map์ Key ๊ฐ์ผ๋ก Class/Struct ๋ฃ๊ธฐ ** ๐๋ชฉํ map์ key๊ฐ์ผ๋ก ๊ธฐ๋ณธ์ ์ธ ๋ฐ์ดํฐ ํ์ (int, string, float, double...)์ด ์๋ ์ฐ๋ฆฌ๊ฐ ์ง์ ๋ง๋ ํ์ (user defined type)์ ๋ฃ์ด๋ณด์. ๐ํน์ง Map์ key(ํค)์ Value(๊ฐ)์ด ์์ผ๋ก ์ด๋ฃจ์ด์ง ์๋ฃ๊ตฌ์กฐ๋ก ํค๋ฅผ ํตํด ๊ฐ์ ์ ๊ทผ ํ ์ ์๋๋ก ๋ง๋ค์ด์ ธ ์๋ค. map์ key(ํค)์ ์ค๋ณต์ ํ์ฉํ์ง ์๊ณ , value(๊ฐ)์ ์ค๋ณต์ ํ์ฉํ๋ค. c++์ map์ ๋ ๋๋ธ๋ํธ๋ฆฌ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌํ์ด ๋์ด์..
![(c++) ์ธ์ฝ๋ฉ(Encoding),์ ๋์ฝ๋(Unicode), ๋ก์ผ์ผ, ํจ์ฏ](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FJjd0m%2FbtsBQQmIqMO%2F8HRKBg2CZdQegJGUFPWFZ0%2Fimg.png)
1. ์ธ์ฝ๋ฉ(Encoding)๋? ์ฝ๋ํ(๋ฌธ์์ ๋ฒํธ๋ฅผ ์ปดํจํฐ์์ ํํํ๋ ๋ฐฉ๋ฒ), ์ํธํ๋ฅผ ์๋ฏธํ๋ฉฐ ๋ฐ๋๋ง์ ๋์ฝ๋ฉ(decoding)์ด๋ค. ์ด๋ค ์ ๋ณด๋ฅผ ์ ํด์ง ๊ท์น์ ๋ฐ๋ผ ๋ณํํ๋ ๊ฒ(en-code-ing)์ ์ผ์ปซ๋๋ค. 2. ์ ๋์ฝ๋(Unicode)๋? ์ ๋์ฝ๋๋ ์ ์ธ๊ณ์ ๋ชจ๋ ๋ฌธ์๋ฅผ ๋ด์ ์ธ๊ณ๊ณตํต ์ฝ๋ ์งํฉ์ ๋ง๋ค์ด ๋ชจ๋๊ฐ ์ด ์งํฉ์ผ๋ก ์ธํด ์ธ์ด๋ฅผ ๊ตฌํํ์๋ ์๋๋ก ๋ง๋ค์ด์ก๋ค. ๊ฐ๋จํ ๋งํด, ์ ๋์ฝ๋(unicode)๋ ๋ชจ๋ ๋ฌธ์์ index๋ฅผ ๋ถ์ฌํ๋ ๊ฒ์ด๋ค. ( index ์ฐธ๊ณ : http://www.unicode.org/charts/) โป ํ๊ธ๊ณผ ๊ฐ์ด ๋ชจ์, ์์, ์ด์ฑ, ์ค์ฑ์ ์กฐํฉ์ผ๋ก ์ฌ๋ฌ๊ฐ์ง ๊ธ์๋ฅผ ํํํ ์ ์๋ ์ธ์ด๋ index๋ก ๋ชจ๋ ์ค ์ ์๋ค. ๊ทธ๋์ ์ ๋์ฝ๋๋ ์์ ํ ๊ธ์๋ฅผ ์ ๊ณตํด..
![(c++) ๋์์ธ ํจํด 01(์ฑ๊ธํค, ์ถ์ ํฉํ ๋ฆฌ, ์ต์ ๋ฒ, ํ๋ก์, ์ด๋ํฐ)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbR993X%2FbtsBOeIEy2t%2FXdkvm5dk5X0bUReNysJwKk%2Fimg.png)
1. ์ฑํดํค(singletion) ํจํด ํ๋์ ํด๋์ค์ ์ค์ง ํ๋์ ์ธ์คํด์ค๋ง ๊ฐ์ง๋ ํจํด์ด๋ค. ๋ณดํต ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฐ๊ฒฐ ๋ชจ๋์ ๋ง์ด ์ฌ์ฉ๋๋ค. ํ๋์ ์ธ์คํด์ค๋ฅผ ๋ง๋ค์ด ๋๊ณ ํด๋น ์ธ์คํด์ค๋ฅผ ๋ค๋ฅธ ๋ชจ๋๋ค์ด ๊ณต์ ํ๋ฉฐ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์ ์ธ์คํด์ค๋ฅผ ์์ฑํ ๋ ๋๋ ๋น์ฉ์ด ์ค์ด๋๋ ์ฅ์ ์ด ์๋ค. ํ์ง๋ง ์์กด์ฑ์ด ๋์์ง๋ค๋ ๋จ์ ์ด ์๋ค. ํ๋ก๊ทธ๋จ์ ๊ตฌํํ ๋ ํด๋์ค์ ์ธ์คํด์ค๊ฐ ๋จ ํ๋๋ง ์กด์ฌํ๊ฒ ๋ง๋ค๋ ค๋ฉด ์ฑ๊ธํด ํจํด์ ์ ์ฉํ๋ฉด ๋๋ค. ์ฑ๊ธํด ํจํด์ ์ ํธ๋ฆฌํฐ ํด๋์ค ๊ตฌํ์ ์ ํฉํ๋ค. ๋ง์ ์ดํ๋ฆฌ์ผ์ด์ ์์๋ ์ํ ์ ๋ณด, ๋๋ฒ๊น ๋ฐ์ดํฐ, ํน์ ํ ์ง์ ์์ ๋ฐ์ํ ์๋ฌ๋ฅผ ๊ธฐ๋กํ๋ ํด๋์ค์ธ ๋ก๊ฑฐ(logger)๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๋ค. ๋ก๊ฑฐ ํด๋์ค๋ ์ฑ๊ธํด์ผ๋ก ๊ตฌํํ๋ ๊ฒ์ด ์ข๋ค. ๊ตฌํ ๋ฐฉ๋ฒ: (1). static ๋ฉ์๋๋ง ๊ฐ์ง..