본문 바로가기

전체 글51

How are C++ objects laid out in memory? 번역 c++ 오브젝트들은 어떻게 메모리에 배치되나요? C 처럼, C++도 레이아웃을 정하지는 않고 반드시 충족해야만하는 의미적 조건만을 정의합니다. 따라서 구현이 다르면 다르게 동작합니다. 아쉽게도, 제가 알고있는 가장 좋은 설명은 구식에 현재 c++ 구현을 설명하지 않는 책에 있습니다: The Annotated C++ Reference Manual (보통 ARM이라고 부릅니다). 이 책에 주 레이아웃 다이어그램 예제가 있습니다. TC++PL의 2챕터에 아주 간단한 설명도 있습니다. 보통, C++은 하위 오브젝트들을 붙여서 간단하게 오브젝트들을 생성합니다. struct A { int a,b; }; 이것은 서로 옆으로 배치된 int 두개로 표현이 되고, struct B : A { int c; }; 이것은 .. 2018. 5. 9.
How do I convert an integer to a string? 번역 integer를 string으로 어떻게 변환하나요? 가장 쉬운방법은 stringstream을 사용하는 방법입니다: #include#include#includeusing namespace std; string itos(int i)// convert int to string{stringstream s;s 2018. 5. 9.
case에 해싱을 통해 string으로 처리하는 것 실제 사용 예 해싱 함수 있는 파일https://github.com/manjaro/mhwd/blob/master/src/Utils.hpp 실제 사용https://github.com/manjaro/mhwd/blob/master/src/Config.cpp 해보기야 했는데 실제로 사용하기도 하네요 설명은 나중에.. 2018. 5. 6.
thread_group #pragma once #include #include #include class thread_group{private: //포인터 컨테이너std::vector container; public:thread_group(){}virtual ~thread_group(){//소멸자 호출시 join 후join_all(); //쓰레드 deletefor(auto& thread : container) delete thread;}; //다른 쓰레드그룹 대입 및 복사 금지thread_group(const thread_group&) = delete;thread_group& operator=(const thread_group&) = delete; //기본 new로 하거나 bind를 통해서 생성된 경우를 위해 template로.. 2018. 4. 24.