본문 바로가기

전체 글465

[C++] Argument Parser (python argparse like) GitHub - junstar92/argparse: C++ (python-argparse-like) Argument Parser C++ (python-argparse-like) Argument Parser. Contribute to junstar92/argparse development by creating an account on GitHub. github.com C++에서 파이썬의 argparse와 유사하게 커맨드라인 인자를 읽을 수 있는 파서를 구현해봤습니다. 파이썬의 argparse와 유사하게 사용할 수 있습니다. 아직 업데이트 중이어서 약간 바뀔 가능성은 있습니다. 기본적은 사용법은 아래와 같습니다. #include #include int main(int argc, char** argv) { a.. 2024. 1. 2.
[C++] Tuple 구현 Reference Ch 25, C++ Templates The Complete Guide Contents Basic Tuple Design Basic Tuple Operations Tuple Algorithms Expanding Tuples Optimizing Tuple 튜플은 실행 프로그램 내의 타입 리스트가 표현된 것이라고 볼 수 있다. 예를 들어, 타입 리스트 Typelist이 컴파일 시간에 조작할 수 있는 int, double, std::string을 가진 타입의 시퀀스를 나타내는 것잉라면 Tuple은 실행 시간에 조작할 수 있는 int, double, std::string에 대한 저장 공간을 나타낸다. 이번 포스팅에서는 C++11에 도입된 std::tuple과 유사한 동작하도록 간략한 버전의 T.. 2024. 1. 1.
[C++] 템플릿과 상속 (EBCO, CRTP) References Ch 21, C++ Templates The Complete Guide Contents The Empty Base Class Optimization (EBCO) The Curiously Recurring Template Pattern (CRTP) The Empty Base Class Optimization (EBCO) 비어있는(empty) C++ 클래스는 런타임에서 메모리를 요구하는 내부 표현이 없다는 것을 의미한다. 일반적으로 타입 멤버, nonvirtual 함수 멤버, 그리고 static 데이터 멤버만을 갖는 클래스를 empty class 라고 한다. 반면, nonstatic 데이터 멤버, virtual 함수, 그리고 virtual base 클래스는 런타임에 메모리를 필요로 한다... 2023. 12. 29.
[C++] Typelists Reference Ch 24, C++ Templates The Complete Guide Contents Typelists Typelist Algorithms Nontype Typelists Optimizing Algorithms with Pack Expansions Cons-style Typelist 효과적인 프로그래밍을 위해서는 다양한 데이터 구조가 필요하다. 메타프로그래밍에서도 동일한데, 메타프로그래밍에서 핵심이 되는 데이터 구조는 타입리스트(typelists)이다. 말 그대로 타입을 포함하고 있는 리스트를 의미한다. 템플릿 메타프로그램은 이러한 타입리스트들을 가지고 조작하면서 실행 프로그램 일부를 만들어낼 수 있다. 이번 포스팅에서는 타입리스트를 다루는 기법에 대해서 살펴볼 예정이다. 타입리스트에.. 2023. 12. 23.
[C++] 메타프로그래밍 Reference Ch 23, C++ Templates The Complete Guide Contents The State of Modern C++ Metaprogramming The Dimensions of Reflective Metaprogramming The Cost of Recursive Instantiation Enumeration Values versus Static Constants 메타프로그래밍(metaprogramming)이란 '프로그램을 프로그래밍하는 것'이다. 즉, 실제로 원하는 기능을 구현하는 새로운 코드를 생성하도록 실행되는 프로그래밍 시스템을 작성하는 것이다. 일반적으로 메타프로그래밍이라는 용어는 반사적(reflexive) 속성을 내포한다. 메타프로그래밍 컴포넌트는 일부 코드를.. 2023. 12. 16.
[C++] Type Erasure Reference Ch22, C++ Template The Complete Guide Contents Function Objects, Pointers, and std::function Bridge Interface Type Erasure Optional Bridging (for lambda) C++에는 정적 다형성(static polymorphism - via template)과 동적 다형성(dynamic polymorphism - via inheritance and virtual function)이 있다. 코드를 작성할 때 두 종류의 다형성으로 강력한 추상화가 가능하지만, 각각에는 장단점이 있다. 정적 다형성은 다형성이 적용되지 않은 일반 코드와 같은 성능을 갖지만, 런타임에 사용할 수 있는 타입 집합.. 2023. 12. 15.
[C++] Overloading on Type Properties References Ch 20, C++ Templates The Complete Guide Contents Algorithm Specialization Tag Dispatching Enabling/Disabling Function Templates 함수 오버로딩(function overloading)은 같은 함수 이름을 여러 함수에서 사용할 수 있도록 하는 것이다. 단, 이러한 함수들은 이 함수들의 파라미터로 구별된다. void f(int); void f(char const*); 함수 템플릿(function templates)에서는 타입 패턴에 오버로드된다. template void f(T*); template void f(Array); Type traits를 생각해 보면 템플릿 인자의 속성을 기반으로 .. 2023. 11. 25.
[C++] Traits(특질) 구현 (3) References Ch 19, C++ Templates The Complete Guide Contents If-Then-Else Detecting Nonthrowing Operations Traits Convenience Type Classification Policy Traits If-Then-Else 아래와 같이 정의된 PlusResultT trait는 HasPlusT 라는 다른 traits에 따른 완전히 다른 구현을 가지고 있다. template struct HasPlusT : std::false_type {}; template struct HasPlusT : std::true_type {}; template struct PlusResultT { using Type = decltype(std::d.. 2023. 11. 24.
컴파일러 개요 References Engineering a Compiler, 2nd 컴파일러의 이해 Contents Compiler Structure Overview of Translations Front End - Scanner, Parser, IR Optimizers Back End - Instruction Selection, Register Allocation, Instruction Scheduling Introduction 모든 컴퓨터 응용프로그램(applications)은 기본 하드웨어에서 제공되는 저수준의 추상화 위에 가상 도구(virtual tools)를 빌드하는 소프트웨어 컴퓨터 프로그램에 의존한다. 거의 모든 소프트웨어는 컴파일러(compiler)라고 부르는 도구를 통해서 번역된다. 컴파일러는 단순히 .. 2023. 10. 14.
NVIDIA 라이브러리 스터디 repo NVIDIA CUDA와 관련하여 스터디 내용을 티스토리에 업데이트하다가 관리하기가 힘들어서 어느 순간부터 깃헙 레포로 변경하여 스터디 내용들을 업데이트하고 있습니다. 특히 CUDA 뿐만 아니라 cuDNN, TensorRT와 관련된 내용들도 업데이트하고 있고 공식 문서 내용에서도 살펴볼만한 내용들을 업데이트하고 있으니 필요하시다면 참조바랍니다 ! GitHub - junstar92/nvidia-libraries-study Contribute to junstar92/nvidia-libraries-study development by creating an account on GitHub. github.com 2023. 7. 30.