본문 바로가기

C++197

[C++20 - STL] Chapter 05. Arithmetic (산술) GitHub : https://github.com/developeSHG/CPP20-STL/commit/342f4dcb3b6b0785b93a2bd700a140547d039af9 Arithmetic (산술) · developeSHG/CPP20-STL@342f4dc developeSHG committed Jul 28, 2023 github.com 게임에서 정수를 생각하면, 사실 음수로 떨어지는 정수가 많이 없을 수 있다. (hp, 경험치, 골드 등등) 양의 숫자만 가지는게 일반적. 그럼에도 불구하고, unsigned를 사용하지 않고, int 사용을 많이 한다. 그럼 unsigned랑 int를 섞었을 때, 일어날 수 있는 문제를 살펴보자. #include using namespace std; #include #.. 2023. 7. 28.
[C++20 - STL] Chapter 04. Container #3 (contains + prefix/suffix checking) GitHub : https://github.com/developeSHG/CPP20-STL/commit/a376fd5e3f93e42f5dff6c6c0cc931f5e5d79ac4 Container #3 (contains + prefix/suffix checking) · developeSHG/CPP20-STL@a376fd5 developeSHG committed Jul 28, 2023 github.com #include using namespace std; #include #include #include #include #include #include #include #include #include // 오늘의 주제 : Container #3 (contains + prefix/suffix checking) /.. 2023. 7. 28.
[C++20 - STL] Chapter 03. Container #2 (erase, erase_if) GitHub :https://github.com/developeSHG/CPP20-STL/commit/9a811599df744777d4644ed08ed25af813a44c55 Container #2 (erase, erase_if) · developeSHG/CPP20-STL@9a81159 developeSHG committed Jul 28, 2023 github.com 중요한 개념. C++을 사용했으면 누구나 한번쯤은 STL 컨테이너의 삭제에 대해 불편한 점을 느껴봤을 것이다. #include using namespace std; #include #include #include #include #include #include #include #include // 오늘의 주제 : Container #2 (er.. 2023. 7. 28.
[C++20 - STL] Chapter 02. Container #1 GitHub : https://github.com/developeSHG/CPP20-STL/commit/42b79d79b6ee7d13ce252069054e62ced1a74b3f Container #1 · developeSHG/CPP20-STL@42b79d7 developeSHG committed Jul 28, 2023 github.com Container #1 1. vector, string 등에 constexpr 사용 가능 algorithm 100개 이상의 함수들이 constexpr로 바뀜 (함수들이 컴파일 타임에 연산이 될 수 있다 라는 개념) 2. std::array 만드는 방법이 추가됨 (std::to_array) 3. std::make_shared로 shared_ptr 배열 생성 // 결론은 2,.. 2023. 7. 28.
[C++20 - STL] Chapter 01. std::span GitHub : https://github.com/developeSHG/CPP20-STL/commit/1244dba491f4a7fb83445a6985fc82194ed14c8f std::span · developeSHG/CPP20-STL@1244dba developeSHG committed Jul 28, 2023 github.com std::span = C배열, std::array, std::vector, std::string 등의 연이은 객체 시퀀스 (contiguous sequence of objects)를 참조(refer) span을 쓰는 이유 { // C타입 배열 // 배열의 길이를 알려면 배열의 크기를 알아야 길이를 알 수가 있었다. int arr[] = { 1,2,3,4,5 }; const in.. 2023. 7. 28.
[C++20 - Language] Chapter 09. using enum in Local Scopes GitHub : https://github.com/developeSHG/CPP20-Language/commit/572b234b3ae4224a14d3d8c1e6be1cb0669745f7 using enum in Local Scopes · developeSHG/CPP20-Language@572b234 developeSHG committed Jul 28, 2023 github.com 지역 범위에서도 using enum을 사용할 수 있다. #include using namespace std; #include #include #include #include #include #include #include #include // 오늘의 주제 : using enum in Local Scopes // 지역 범위에서도 u.. 2023. 7. 28.
[C++20 - Language] Chapter 08. Ranged-Based For With Initializer GitHub : https://github.com/developeSHG/CPP20-Language/commit/4c6659245e232ea11de584fa3f887cfb7b294f28 Range-Based For Loop With Initializer · developeSHG/CPP20-Language@4c66592 developeSHG committed Jul 28, 2023 github.com 범위 기반 루프문에 대해서도 이니셜라이저를 사용하게 될 수 있다. #include using namespace std; #include #include #include #include #include #include #include #include // 오늘의 주제 : Range-Based For Loop Wi.. 2023. 7. 28.
[C++20 - Language] Chapter 07. Attribute GitHub : https://github.com/developeSHG/CPP20-Language/commit/c46e09e7366f9737c0044379b7ba6e38ff911c20 Attribute · developeSHG/CPP20-Language@c46e09e developeSHG committed Jul 28, 2023 github.com 힌트를 줘서 추가적으로 컴파일러가 warning을 잡아주는 기능. 컴파일러한테 걸어주는 주석같은 느낌. #include using namespace std; #include #include #include #include #include #include #include #include // 오늘의 주제 : Attribute // 힌트를 줘서 추가적으로 컴파일러.. 2023. 7. 28.
[C++20 - Language] Chapter 06. Template Parameter for Lambda GitHub : https://github.com/developeSHG/CPP20-Language/commit/5bc08499e32d6f494c62d23587c2900f65e4f1e4 Template Parameter for Lambda · developeSHG/CPP20-Language@5bc0849 developeSHG committed Jul 28, 2023 github.com 템플릿을 람다와 혼합해서 사용할 수 있다. #include using namespace std; #include #include #include #include #include #include #include #include // 오늘의 주제 : Template Parameter for Lambda // 템플릿을 람다와 혼합.. 2023. 7. 28.
[C++20 - Language] Chapter 05. Non-Type Template Parameter GitHub : https://github.com/developeSHG/CPP20-Language/commit/84f811e96a0a5518f76a242fc3ec07777d3067c7 Non-Type Template Parameter · developeSHG/CPP20-Language@84f811e developeSHG committed Jul 28, 2023 github.com 일방적으로 템플릿을 사용할 때, 어떤 타입에 대응해서 치환을 하게끔 설정했는데 경우에 따라서 지정된 타입(int 등)으로도 사용했었다. 그래서 Non-Type에 대해서만 들어갔었는데, C++20로 넘어오면서 추가된 것들이 생겼다. 보다보면 약간 흑마법같은 기능. // Non-Type // - int, enum // - 포인터, .. 2023. 7. 28.