본문 바로가기

SW 지식/C 와 C++ 공부

(9)
[C#] Struct로 바꿨을 때 성능 장점 설명(스크랩) 최근 성능 때문에 class를 struct로 바꾸는 것에 관해 이야기를 하였다. 아래 글이 몹시 친절하게 설명되어 있어 스크랩 겸 오랜만에 글을 쓴다 :) https://kukuta.tistory.com/385 [C#] C# 구조체(struct)로 메모리 절약하기 들어가며 C++에 익숙한 사용자라면 class와 struct의 차이라고 해봐야 멤버에 대한 기본 접근한정이 private이냐 public이냐 정도차이 라고 알고 있을 것이다. 하지만 C#에서는 class와 struct의 차이가 매 kukuta.tistory.com Unity에서도 과거에 이러한 경험이 있었다고 한다. "과거 한동안 Unity는 구조체에 대한 직렬화를 지원하지 않았으므로 직렬화가 필요한 모든 구조적인 데이터 타입은 클래스여야만 했..
[C++] std::get 에 대해 알아보자 [TBD] 출처 : https://en.cppreference.com/w/cpp/utility/tuple/get
[C++] std::pair와 std::tuple [TBD] tuple의 사전적 정의 -tuple 접미사 앞에 숫자를 붙여 「한 벌의 것」의 뜻을 나타냄 e.g. a 3--tuple ...? 이해는 되지만, 다른 의미일 수도 있어서 찾아보았더니 Wikipedia에서 아래와 같은 정보를 찾았습니다. In mathematics, a tuple is a finite ordered list (sequence) of elements. An n-tuple is a sequence (or ordered list) of n elements, where n is a non-negative integer. ... In computer science, tuples come in many forms. Most typed functional programming languages imp..
[C++] emplace 함수 emplace의 사전적 정의 emplace 타동사 1. 설치하다 2. 관입하다 3. 발달하다 이처럼 emplace 함수는, C++11부터 들어간 함수로, push() 함수와 비슷한 기능을 합니다. ("Insert a new element") 지난 게시물에서 배운, std::unordered_map 뿐만 아니라, std::vector 에도 있는 함수였습니다! 이 페이지에선 unordered_map의 emplace() 함수로 설명 및 예시를 들어보겠습니다. Inserts a new element into the container constructed in-place with the given args if there is no element with the key in the container. Carefu..
[C++] unordered_map 컨테이너 unordered_map 은 C++ STL 중 하나로, map보다 더 빠른 탐색을 위해 성능이 개선된 자료구조입니다. Unordered maps are associative containers that store elements formed by the combination of a key value and a mapped value, and which allows for fast retrieval of individual elements based on their keys. Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of eleme..
[C++] std::function 은 무엇일까 std::function은, Class template std::function is a general-purpose polymorphic function wrapper. Instances of std::function can store, copy, and invoke any CopyConstructible Callable target -- functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members. The stored callable object is called the target of std::func..
[C++] 람다 식 Lambda expressions lambda 의 사전적 정의 lambda 명사 1. 람다(Λ, λ): 그리스어 알파벳의 열한째 자모. (참고 - 영어에서는 L, l로 표기됨.) 2. [화학] 람다: 체적의 단위; =10⁻³cm³, 10⁻⁶liter. 3. [물리] 람다 입자(粒子)(lambda particle): hyperon의 하나. 4. [유전학] 람다 파지: 대장균의 유전자를 도입하고 다른 데로 전송 하는 능력을 가짐. 그렇다면, C++에서 나오는 lambda 식은 무엇일까? Lambda expressions (since C++11) Constructs a closure: an unnamed function object capable of capturing variables in scope. -> 범위 내에서 변수를 캡처할 수 있..
[C++] mutable 변수 mutable의 사전적 정의 mutable 형용사 1.변덕스러운 2.변하기 쉬운 3.가변성의 그렇다면, C++에서 나오는 mutable 키워드는 무엇일까? mutable specifier mutable - permits modification of the class member declared mutable even if the containing object is declared const. 즉, 객체가 const로 선언된 경우에도 변경 가능하도록 허용한다는 것을 나타낼 때 사용! 예를 들어, struct MyInfo { int a; mutable int b; }; void main() { const MyInfo value = {5,8}; value.a = 4; // 에러 value.b = 7; } 이..