Rico's Nerd Cluster

「离开世界之前 一切都是过程」

C++ - [Container 1] Associative Container

std::set, std::unordered_set, std::map, std::unordered_map, std::multiset, std::unordered_multiset, std::unordered_multimap

Introduction Associative containers in C++ are containers that allows fast retrieval of elements based on keys, rather than positions. Construction: std::set, and std::map also have sorting us...

C++ - Pointers

Raw Pointers, Array, Casting

Raw Pointers 🚀 Basics new and delete: If you use new, you must use delete — otherwise, memory leak! see code. new[]:size must be provided as part of the signature. ...

C++ - BLAS and LAPACK

Scientific Computing Libraries

Article: BLAS (“Basic Linear Algebra Subalgorithms”) BLAS is a set of specifications of linear algebra operations such as vector addition, scalar multiplication, dot products, etc. It’s categorize...

C++ - Casting

Ever tried convincing your boss that your need for vacation is a 'const' by using const_cast? Welcome to C++ casting!

Introduction TODO - coming soon ;) Const Casting ❗ const_cast is needed sometimes to form a pointer/reference to a const object to interface with legacy code. Modifying the char* might lead to u...

C++ - Numeric

NaN

std::numeric NaN: (C++11) std::numeric_limits<float>::quiet_NaN(): propagates through arithmetic operations without triggering floating-point exceptions. 1 2 3 4 5 6 7 8 9 10 11 12 flo...

C++ - , Functions

minmax_element, min_element, reduce, transform, numeric

Introduction In this article, we will explore two important STL libraries, <algorithm>, <numeric>. In <algorithm>, we have: Partitioning algorithms: Placing the n...

C++ - Sizing and Type Conversion

Memory Alignment, Sizeof, Integral Promotion

Memory Alignment C++ struct / class does memory alignment. Here’s an illustrative example: 1 2 3 4 5 struct LocalizationData { float x, y; // Each float is 4 bytes bool r; // bool i...

C++ - Control Flow

switch-case, cpp20 range, DSL

switch-case Like goto, switch-case is a label. Without {}, any variable declared within a switch-case statement has the scope of the entire statement. This will only work with variables that can b...

C++ - Macros

Why Macros, Compiler Args

Introduction Macros are string substitution for code. It happens during the preprocessing phase. It is generally not encouraged in c++ nowadays. However, there are still applications where it coul...

C++ - Lvalue and Rvalue Reference

Reference Lifetime

Reference Lifetime const lvalue reference Simply Extends the Lifetime of A Temp. No copy constructor is called when the temp object is passed in const lvalue reference as a class attribute DO...