A little Introduction to Control Flow Integrity - James McNellis - Keynote Meeting C++ 2025
https://www.youtube.com/watch?v=_eX7AVB4qzM
https://redd.it/1pty5kj
@r_cpp
https://www.youtube.com/watch?v=_eX7AVB4qzM
https://redd.it/1pty5kj
@r_cpp
Reddit
From the cpp community on Reddit: A little Introduction to Control Flow Integrity - James McNellis - Keynote Meeting C++ 2025
Explore this post and more from the cpp community
tieredsort - 3.8x faster than std::sort for integers, header-only
Made a sorting library that detects data patterns before sorting.
Results (n=100k):
Random: 3.8x faster than std::sort, 1.6x faster than ska_sort
Dense data (ages, sensors): 30x faster than std::sort, 9x faster than ska_sort
The idea: real data isn't random. Ages are 0-100. Sensors are 12-bit. When the range is small, counting sort beats everything.
Detection cost: 12 comparisons + 64 samples. Negligible.
C++17, header-only, no SIMD needed.
GitHub: https://github.com/Cranot/tieredsort
Looking for feedback on edge cases I might have missed.
https://redd.it/1pu554f
@r_cpp
Made a sorting library that detects data patterns before sorting.
Results (n=100k):
Random: 3.8x faster than std::sort, 1.6x faster than ska_sort
Dense data (ages, sensors): 30x faster than std::sort, 9x faster than ska_sort
The idea: real data isn't random. Ages are 0-100. Sensors are 12-bit. When the range is small, counting sort beats everything.
Detection cost: 12 comparisons + 64 samples. Negligible.
C++17, header-only, no SIMD needed.
GitHub: https://github.com/Cranot/tieredsort
Looking for feedback on edge cases I might have missed.
https://redd.it/1pu554f
@r_cpp
GitHub
GitHub - Cranot/tieredsort: A fast, header-only C++17 sorting library for numeric types. 3.6x faster than std::sort, up to 21x…
A fast, header-only C++17 sorting library for numeric types. 3.6x faster than std::sort, up to 21x on dense data - Cranot/tieredsort
Is this the end of C++ at Microsoft?
Given the goals and push for Rust https://www.linkedin.com/posts/galenh_principal-software-engineer-coreai-microsoft-activity-7407863239289729024-WTzf
https://redd.it/1pu6cf7
@r_cpp
Given the goals and push for Rust https://www.linkedin.com/posts/galenh_principal-software-engineer-coreai-microsoft-activity-7407863239289729024-WTzf
https://redd.it/1pu6cf7
@r_cpp
Linkedin
Principal Software Engineer (CoreAI) | Microsoft Careers | Galen Hunt | 31 comments
Update:
It appears my post generated far more attention than I intended... with a lot of speculative reading between the lines.
Just to clarify... Windows is *NOT* being rewritten in Rust with AI.
My team’s project is a research project. We are building…
It appears my post generated far more attention than I intended... with a lot of speculative reading between the lines.
Just to clarify... Windows is *NOT* being rewritten in Rust with AI.
My team’s project is a research project. We are building…
New 0-copy deserialization protocol
Hello all! Seems like serialization is a popular topic these days for some reason...
I've posted before about the c++ library "zerialize" (https://github.com/colinator/zerialize), which offers serialization/deserialization and translation across multiple dynamic (self-describing) serialization formats, including json, flexbuffers, cbor, and message pack. The big benefit is that when the underlying protocol supports it, it supports 0-copy deserialization, including directly into xtensor/eigen matrices.
Well, I've added two things to it:
1) Run-time serialization. Before this, you would have to define your serialized objects at compile-time. Now you can do it at run-time too (although, of course, it's slower).
2) A new built-in protocol! I call it "ZERA" for ZERo-copy Arena". With all other protocols, I cannot guarantee that tensors will be properly aligned when 'coming off the wire', and so the tensor deserialization will perform a copy if the data isn't properly aligned. ZERA _does_ support this though - if the caller can guarantee that the underlying bytes are, say, 8-byte aligned, then everything inside the message will also be properly aligned. This results in the fastest 0-copy tensor deserialization, and works well for SIMD etc. And it's fast (but not compact)! Check out the benchmark_compare directory.
Definitely open to feedback or requests!
https://redd.it/1pu6zwe
@r_cpp
Hello all! Seems like serialization is a popular topic these days for some reason...
I've posted before about the c++ library "zerialize" (https://github.com/colinator/zerialize), which offers serialization/deserialization and translation across multiple dynamic (self-describing) serialization formats, including json, flexbuffers, cbor, and message pack. The big benefit is that when the underlying protocol supports it, it supports 0-copy deserialization, including directly into xtensor/eigen matrices.
Well, I've added two things to it:
1) Run-time serialization. Before this, you would have to define your serialized objects at compile-time. Now you can do it at run-time too (although, of course, it's slower).
2) A new built-in protocol! I call it "ZERA" for ZERo-copy Arena". With all other protocols, I cannot guarantee that tensors will be properly aligned when 'coming off the wire', and so the tensor deserialization will perform a copy if the data isn't properly aligned. ZERA _does_ support this though - if the caller can guarantee that the underlying bytes are, say, 8-byte aligned, then everything inside the message will also be properly aligned. This results in the fastest 0-copy tensor deserialization, and works well for SIMD etc. And it's fast (but not compact)! Check out the benchmark_compare directory.
Definitely open to feedback or requests!
https://redd.it/1pu6zwe
@r_cpp
GitHub
GitHub - colinator/zerialize: Zero-copy multi-format serialization for c++.
Zero-copy multi-format serialization for c++. Contribute to colinator/zerialize development by creating an account on GitHub.
Wait-Free Chunked I/O Buffer
We’re building a database and recently implemented a custom `I/O buffer` to handle the Postgres wire protocol. We considered `folly::IOBuf` and `absl::Cord`, but decided to implement a specialized version to avoid mutexes and simplify "late" size-prefixing.
**Key Technical Features:**
* **Chunked Storage:** Prevents large reallocations and minimizes `memcpy` by using a chain of fixed-size buffers.
* **Wait-Free:** Designed for high-concurrency network I/O without mutex contention.
* **Uncommitted Writes:** Allows reserving space at the start of a message for a size prefix that is only known after the payload is serialized, avoiding data shifts.
**Why custom?** Most generic "Cord" implementations were either slow or not truly concurrent. Our buffer allows one writer and one reader to work at the same time without locks and it actually works quite well to the benchmarks.
**Code & Details:**
* [Benchmarks & Blog Post](https://www.serenedb.com/blog/io-buffer)
* [Source Code (GitHub)](https://github.com/serenedb/serenedb/blob/main/libs/basics/message_buffer.h)
I'd love to hear your thoughts on our approach and if anyone has seen similar wins by moving away from `std::mutex` in their transport layers.
https://redd.it/1pu8cfs
@r_cpp
We’re building a database and recently implemented a custom `I/O buffer` to handle the Postgres wire protocol. We considered `folly::IOBuf` and `absl::Cord`, but decided to implement a specialized version to avoid mutexes and simplify "late" size-prefixing.
**Key Technical Features:**
* **Chunked Storage:** Prevents large reallocations and minimizes `memcpy` by using a chain of fixed-size buffers.
* **Wait-Free:** Designed for high-concurrency network I/O without mutex contention.
* **Uncommitted Writes:** Allows reserving space at the start of a message for a size prefix that is only known after the payload is serialized, avoiding data shifts.
**Why custom?** Most generic "Cord" implementations were either slow or not truly concurrent. Our buffer allows one writer and one reader to work at the same time without locks and it actually works quite well to the benchmarks.
**Code & Details:**
* [Benchmarks & Blog Post](https://www.serenedb.com/blog/io-buffer)
* [Source Code (GitHub)](https://github.com/serenedb/serenedb/blob/main/libs/basics/message_buffer.h)
I'd love to hear your thoughts on our approach and if anyone has seen similar wins by moving away from `std::mutex` in their transport layers.
https://redd.it/1pu8cfs
@r_cpp
Serenedb
Blog | SereneDB
C++ is actually a great language for LLMs
I remember hearing a few months ago that c++ isn't a great language for tools like copilot, cursor or IDE replacements. Personally, it's really integrated into my workflow and I want to say I'm having a lot of positive experiences. So I wanted to share that a bit to those still in the mindset that these tools are a negative.
For one, I keep my scope small. I try to provide just the context it needs. Sometimes I will checkout the code of a third party library just so it can pull in that context if it needs. I can't provide all the best advice on this, because some of it has nothing to do with the language, other people have written great articles, and this is a skill you develop over time.
But for small and large wins, c++ is a great language. Questions like "are there any unnecessary string copies?", "are there any objects that are accidentally being passed by value?", to more beefy stuff like improving the performance of individual functions, or removing unnecessary blocks in your threading lifecycle. It understands the cost of memory allocations if you tell it that is important, flatten data structures to keep it contiguous, and it will adhere to the design of your codebase.
Anyway, I'm having a lot of fun with cursor in a c++ codebase and just wanted to evangelize a little - if you haven't integrated this into your codebase then you really are missing a very fundamental shift in software engineering role.
I will also say that there is such a variance in AI tools. I like neovim, but having to provide the context of individual files was painful. Cursor is able to use external tools to perform its job and search. The use of one vs the use of the other feel like performing a completely different role (neovim + plugins might be better now I don't know).
And a caveat: these tools can be used negatively and carelessly. I'm not here to argue that some form of SWE hasn't degraded, especially when you're working with coworkers who aren't taking care in their use. The trick is to keep the scope small, tell it what is important to you in your codebase, and increase the scope as you get more comfortable with the tool.
https://redd.it/1pu78s9
@r_cpp
I remember hearing a few months ago that c++ isn't a great language for tools like copilot, cursor or IDE replacements. Personally, it's really integrated into my workflow and I want to say I'm having a lot of positive experiences. So I wanted to share that a bit to those still in the mindset that these tools are a negative.
For one, I keep my scope small. I try to provide just the context it needs. Sometimes I will checkout the code of a third party library just so it can pull in that context if it needs. I can't provide all the best advice on this, because some of it has nothing to do with the language, other people have written great articles, and this is a skill you develop over time.
But for small and large wins, c++ is a great language. Questions like "are there any unnecessary string copies?", "are there any objects that are accidentally being passed by value?", to more beefy stuff like improving the performance of individual functions, or removing unnecessary blocks in your threading lifecycle. It understands the cost of memory allocations if you tell it that is important, flatten data structures to keep it contiguous, and it will adhere to the design of your codebase.
Anyway, I'm having a lot of fun with cursor in a c++ codebase and just wanted to evangelize a little - if you haven't integrated this into your codebase then you really are missing a very fundamental shift in software engineering role.
I will also say that there is such a variance in AI tools. I like neovim, but having to provide the context of individual files was painful. Cursor is able to use external tools to perform its job and search. The use of one vs the use of the other feel like performing a completely different role (neovim + plugins might be better now I don't know).
And a caveat: these tools can be used negatively and carelessly. I'm not here to argue that some form of SWE hasn't degraded, especially when you're working with coworkers who aren't taking care in their use. The trick is to keep the scope small, tell it what is important to you in your codebase, and increase the scope as you get more comfortable with the tool.
https://redd.it/1pu78s9
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Why do I rarely come across 'using namespace std?'
For context, I'm pretty new to this language. I'm about halfway through 'C++ A Beginners Guide by Herbert Schildt,' but I have explored the language past this book (embedded things).
In the book, the standard namespace is used for every program.
In C++ programs that I typically see, std:: is used (e.g., std::cout).
Is there a disadvantage to using the namespace? Is it that it's outdated?
(The book im reading is from the early 2000's)
https://redd.it/1pubujb
@r_cpp
For context, I'm pretty new to this language. I'm about halfway through 'C++ A Beginners Guide by Herbert Schildt,' but I have explored the language past this book (embedded things).
In the book, the standard namespace is used for every program.
In C++ programs that I typically see, std:: is used (e.g., std::cout).
Is there a disadvantage to using the namespace? Is it that it's outdated?
(The book im reading is from the early 2000's)
https://redd.it/1pubujb
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
All the other cool languages have try...finally. C++ says "We have try...finally at home."
https://devblogs.microsoft.com/oldnewthing/20251222-00/?p=111890
https://redd.it/1pudexb
@r_cpp
https://devblogs.microsoft.com/oldnewthing/20251222-00/?p=111890
https://redd.it/1pudexb
@r_cpp
Microsoft News
All the other cool languages have try…finally. C++ says “We have try…finally at home.”
The destructor serves as the "finally".
Any addition to my Roadmap.
C++ PROGRAMMING
Topics
GENERAL
ALGORITHMS AND DATA STRUCTURES
Data structures
- Arrays and Vectors
- Linked Lists
- Stacks and Queues
- Trees (BST, AVL, Red-Black)
- Graphs
- Hash Tables
- Heaps
Algorithms
- Sorting
- Searching
- Graph Algorithms
- Dynamic Programming
- Greedy Algorithms
CODE QUALITY
Core principles
- SOLID Principles
- DRY, KISS, YAGNI
Design Patterns
- Creational
- Structural
- Behavioral
Clean Code
- Naming Conventions
- Code Organization
Tools
- Linters
- Static Analyzers
- Profilers
C++ CORE
BASIC SYNTAX
Variables and Constants
Data Types
Operators
Comments
Input/Output (cin, cout)
Namespaces
CONTROL FLOW
Conditional Statements
- if, else if, else
- switch-case
Loops
- for, while, do-while
- Range-based for loop
Jump Statements
- break, continue, return
- goto
FUNCTIONS
Function Declaration
Function Definition
Function Overloading
Default Arguments
Inline Functions
Recursion
Function Pointers
Lambda Expressions
OBJECT-ORIENTED PROGRAMMING
Classes and Objects
- Class Definition
- Access Specifiers (public, private, protected)
- Member Functions
- Member Variables
Constructors
- Default Constructor
- Parameterized Constructor
- Copy Constructor
- Move Constructor
Destructors
this Pointer
Static Members
Friend Functions and Classes
Const Member Functions
INHERITANCE
Single Inheritance
Multiple Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Virtual Base Classes
Access Control in Inheritance
Constructor/Destructor Order
POLYMORPHISM
Compile-time Polymorphism
- Function Overloading
- Operator Overloading
Runtime Polymorphism
- Virtual Functions
- Pure Virtual Functions
- Abstract Classes
- Virtual Destructors
Virtual Function Table (vtable)
ENCAPSULATION AND ABSTRACTION
Data Hiding
Getter and Setter Methods
Abstract Classes
Interfaces
POINTERS AND REFERENCES
Pointers
- Pointer Basics
- Pointer Arithmetic
- Pointers to Objects
- this Pointer
- Function Pointers
References
- Lvalue References
- Rvalue References
- Reference vs Pointer
Dynamic Memory
- new and delete
- new and delete
- Memory Leaks
TEMPLATES
Function Templates
Class Templates
Template Specialization
Variadic Templates
Template Metaprogramming
SFINAE
STANDARD TEMPLATE LIBRARY (STL)
CONTAINERS
Sequence Containers
- vector
- deque
- list
- array
- forwardlist
Associative Containers
- set, multiset
- map, multimap
Unordered Containers
- unorderedset
- unorderedmap
Container Adaptors
- stack
- queue
- priorityqueue
ITERATORS
Iterator Types
Iterator Operations
Iterator Invalidation
Reverse Iterators
ALGORITHMS
Non-modifying
- find, count, search
Modifying
- copy, move, transform
Sorting
- sort, stablesort, partialsort
Binary Search
Set Operations
Heap Operations
FUNCTORS AND LAMBDA
Function Objects
Lambda Expressions
std::function
std::bind
MODERN C++ (C++11/14/17/20/23)
C++11 FEATURES
Auto keyword
Range-based for loops
nullptr
Move
C++ PROGRAMMING
Topics
GENERAL
ALGORITHMS AND DATA STRUCTURES
Data structures
- Arrays and Vectors
- Linked Lists
- Stacks and Queues
- Trees (BST, AVL, Red-Black)
- Graphs
- Hash Tables
- Heaps
Algorithms
- Sorting
- Searching
- Graph Algorithms
- Dynamic Programming
- Greedy Algorithms
CODE QUALITY
Core principles
- SOLID Principles
- DRY, KISS, YAGNI
Design Patterns
- Creational
- Structural
- Behavioral
Clean Code
- Naming Conventions
- Code Organization
Tools
- Linters
- Static Analyzers
- Profilers
C++ CORE
BASIC SYNTAX
Variables and Constants
Data Types
Operators
Comments
Input/Output (cin, cout)
Namespaces
CONTROL FLOW
Conditional Statements
- if, else if, else
- switch-case
Loops
- for, while, do-while
- Range-based for loop
Jump Statements
- break, continue, return
- goto
FUNCTIONS
Function Declaration
Function Definition
Function Overloading
Default Arguments
Inline Functions
Recursion
Function Pointers
Lambda Expressions
OBJECT-ORIENTED PROGRAMMING
Classes and Objects
- Class Definition
- Access Specifiers (public, private, protected)
- Member Functions
- Member Variables
Constructors
- Default Constructor
- Parameterized Constructor
- Copy Constructor
- Move Constructor
Destructors
this Pointer
Static Members
Friend Functions and Classes
Const Member Functions
INHERITANCE
Single Inheritance
Multiple Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Virtual Base Classes
Access Control in Inheritance
Constructor/Destructor Order
POLYMORPHISM
Compile-time Polymorphism
- Function Overloading
- Operator Overloading
Runtime Polymorphism
- Virtual Functions
- Pure Virtual Functions
- Abstract Classes
- Virtual Destructors
Virtual Function Table (vtable)
ENCAPSULATION AND ABSTRACTION
Data Hiding
Getter and Setter Methods
Abstract Classes
Interfaces
POINTERS AND REFERENCES
Pointers
- Pointer Basics
- Pointer Arithmetic
- Pointers to Objects
- this Pointer
- Function Pointers
References
- Lvalue References
- Rvalue References
- Reference vs Pointer
Dynamic Memory
- new and delete
- new and delete
- Memory Leaks
TEMPLATES
Function Templates
Class Templates
Template Specialization
Variadic Templates
Template Metaprogramming
SFINAE
STANDARD TEMPLATE LIBRARY (STL)
CONTAINERS
Sequence Containers
- vector
- deque
- list
- array
- forwardlist
Associative Containers
- set, multiset
- map, multimap
Unordered Containers
- unorderedset
- unorderedmap
Container Adaptors
- stack
- queue
- priorityqueue
ITERATORS
Iterator Types
Iterator Operations
Iterator Invalidation
Reverse Iterators
ALGORITHMS
Non-modifying
- find, count, search
Modifying
- copy, move, transform
Sorting
- sort, stablesort, partialsort
Binary Search
Set Operations
Heap Operations
FUNCTORS AND LAMBDA
Function Objects
Lambda Expressions
std::function
std::bind
MODERN C++ (C++11/14/17/20/23)
C++11 FEATURES
Auto keyword
Range-based for loops
nullptr
Move
Any addition to my Roadmap.
C++ PROGRAMMING
Topics
GENERAL
ALGORITHMS AND DATA STRUCTURES
Data structures
- Arrays and Vectors
- Linked Lists
- Stacks and Queues
- Trees (BST, AVL, Red-Black)
- Graphs
- Hash Tables
- Heaps
Algorithms
- Sorting
- Searching
- Graph Algorithms
- Dynamic Programming
- Greedy Algorithms
CODE QUALITY
Core principles
- SOLID Principles
- DRY, KISS, YAGNI
Design Patterns
- Creational
- Structural
- Behavioral
Clean Code
- Naming Conventions
- Code Organization
Tools
- Linters
- Static Analyzers
- Profilers
C++ CORE
BASIC SYNTAX
Variables and Constants
Data Types
Operators
Comments
Input/Output (cin, cout)
Namespaces
CONTROL FLOW
Conditional Statements
- if, else if, else
- switch-case
Loops
- for, while, do-while
- Range-based for loop
Jump Statements
- break, continue, return
- goto
FUNCTIONS
Function Declaration
Function Definition
Function Overloading
Default Arguments
Inline Functions
Recursion
Function Pointers
Lambda Expressions
OBJECT-ORIENTED PROGRAMMING
Classes and Objects
- Class Definition
- Access Specifiers (public, private, protected)
- Member Functions
- Member Variables
Constructors
- Default Constructor
- Parameterized Constructor
- Copy Constructor
- Move Constructor
Destructors
this Pointer
Static Members
Friend Functions and Classes
Const Member Functions
INHERITANCE
Single Inheritance
Multiple Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Virtual Base Classes
Access Control in Inheritance
Constructor/Destructor Order
POLYMORPHISM
Compile-time Polymorphism
- Function Overloading
- Operator Overloading
Runtime Polymorphism
- Virtual Functions
- Pure Virtual Functions
- Abstract Classes
- Virtual Destructors
Virtual Function Table (vtable)
ENCAPSULATION AND ABSTRACTION
Data Hiding
Getter and Setter Methods
Abstract Classes
Interfaces
POINTERS AND REFERENCES
Pointers
- Pointer Basics
- Pointer Arithmetic
- Pointers to Objects
- this Pointer
- Function Pointers
References
- Lvalue References
- Rvalue References
- Reference vs Pointer
Dynamic Memory
- new and delete
- new[] and delete[]
- Memory Leaks
TEMPLATES
Function Templates
Class Templates
Template Specialization
Variadic Templates
Template Metaprogramming
SFINAE
STANDARD TEMPLATE LIBRARY (STL)
CONTAINERS
Sequence Containers
- vector
- deque
- list
- array
- forward_list
Associative Containers
- set, multiset
- map, multimap
Unordered Containers
- unordered_set
- unordered_map
Container Adaptors
- stack
- queue
- priority_queue
ITERATORS
Iterator Types
Iterator Operations
Iterator Invalidation
Reverse Iterators
ALGORITHMS
Non-modifying
- find, count, search
Modifying
- copy, move, transform
Sorting
- sort, stable_sort, partial_sort
Binary Search
Set Operations
Heap Operations
FUNCTORS AND LAMBDA
Function Objects
Lambda Expressions
std::function
std::bind
MODERN C++ (C++11/14/17/20/23)
C++11 FEATURES
Auto keyword
Range-based for loops
nullptr
Move
C++ PROGRAMMING
Topics
GENERAL
ALGORITHMS AND DATA STRUCTURES
Data structures
- Arrays and Vectors
- Linked Lists
- Stacks and Queues
- Trees (BST, AVL, Red-Black)
- Graphs
- Hash Tables
- Heaps
Algorithms
- Sorting
- Searching
- Graph Algorithms
- Dynamic Programming
- Greedy Algorithms
CODE QUALITY
Core principles
- SOLID Principles
- DRY, KISS, YAGNI
Design Patterns
- Creational
- Structural
- Behavioral
Clean Code
- Naming Conventions
- Code Organization
Tools
- Linters
- Static Analyzers
- Profilers
C++ CORE
BASIC SYNTAX
Variables and Constants
Data Types
Operators
Comments
Input/Output (cin, cout)
Namespaces
CONTROL FLOW
Conditional Statements
- if, else if, else
- switch-case
Loops
- for, while, do-while
- Range-based for loop
Jump Statements
- break, continue, return
- goto
FUNCTIONS
Function Declaration
Function Definition
Function Overloading
Default Arguments
Inline Functions
Recursion
Function Pointers
Lambda Expressions
OBJECT-ORIENTED PROGRAMMING
Classes and Objects
- Class Definition
- Access Specifiers (public, private, protected)
- Member Functions
- Member Variables
Constructors
- Default Constructor
- Parameterized Constructor
- Copy Constructor
- Move Constructor
Destructors
this Pointer
Static Members
Friend Functions and Classes
Const Member Functions
INHERITANCE
Single Inheritance
Multiple Inheritance
Multilevel Inheritance
Hierarchical Inheritance
Virtual Base Classes
Access Control in Inheritance
Constructor/Destructor Order
POLYMORPHISM
Compile-time Polymorphism
- Function Overloading
- Operator Overloading
Runtime Polymorphism
- Virtual Functions
- Pure Virtual Functions
- Abstract Classes
- Virtual Destructors
Virtual Function Table (vtable)
ENCAPSULATION AND ABSTRACTION
Data Hiding
Getter and Setter Methods
Abstract Classes
Interfaces
POINTERS AND REFERENCES
Pointers
- Pointer Basics
- Pointer Arithmetic
- Pointers to Objects
- this Pointer
- Function Pointers
References
- Lvalue References
- Rvalue References
- Reference vs Pointer
Dynamic Memory
- new and delete
- new[] and delete[]
- Memory Leaks
TEMPLATES
Function Templates
Class Templates
Template Specialization
Variadic Templates
Template Metaprogramming
SFINAE
STANDARD TEMPLATE LIBRARY (STL)
CONTAINERS
Sequence Containers
- vector
- deque
- list
- array
- forward_list
Associative Containers
- set, multiset
- map, multimap
Unordered Containers
- unordered_set
- unordered_map
Container Adaptors
- stack
- queue
- priority_queue
ITERATORS
Iterator Types
Iterator Operations
Iterator Invalidation
Reverse Iterators
ALGORITHMS
Non-modifying
- find, count, search
Modifying
- copy, move, transform
Sorting
- sort, stable_sort, partial_sort
Binary Search
Set Operations
Heap Operations
FUNCTORS AND LAMBDA
Function Objects
Lambda Expressions
std::function
std::bind
MODERN C++ (C++11/14/17/20/23)
C++11 FEATURES
Auto keyword
Range-based for loops
nullptr
Move
Semantics
Perfect Forwarding
Smart Pointers
constexpr
Initializer Lists
Delegating Constructors
C++14 FEATURES
Generic Lambdas
Return Type Deduction
Binary Literals
Variable Templates
C++17 FEATURES
Structured Bindings
if/switch with initializers
std::optional
std::variant
std::any
Fold Expressions
Inline Variables
C++20 FEATURES
Concepts
Ranges
Coroutines
Modules
Three-way Comparison (<=>)
std::span
MEMORY MANAGEMENT
Stack vs Heap
RAII (Resource Acquisition Is Initialization)
Smart Pointers
- unique_ptr
- shared_ptr
- weak_ptr
Custom Allocators
Memory Pools
EXCEPTION HANDLING
try-catch blocks
throw keyword
Exception Classes
Standard Exceptions
noexcept specifier
Exception Safety Guarantees
FILE I/O
Stream Classes
- ifstream, ofstream, fstream
File Operations
Binary File I/O
String Streams
Formatting
MULTITHREADING
std::thread
Mutexes and Locks
Condition Variables
Atomic Operations
Thread-local Storage
Futures and Promises
async
PREPROCESSOR
Macros
#include
Header Guards
#pragma once
Conditional Compilation
ADVANCED TOPICS
Type Casting
- static_cast
- dynamic_cast
- const_cast
- reinterpret_cast
RTTI (Runtime Type Information)
Operator Overloading
Copy Elision and RVO
Perfect Forwarding
Name Mangling
Linkage
COMPILATION AND BUILD
Compilation Process
Header Files
Source Files
Linking
Build Systems
- Make
- CMake
Compiler Options
Requested a AI to provide a CPP roadmap to know CPP very thoroughly, and it has provided me this roadmap. Do you have additions? Or is this good for modern CPP?
https://redd.it/1pug6hs
@r_cpp
Perfect Forwarding
Smart Pointers
constexpr
Initializer Lists
Delegating Constructors
C++14 FEATURES
Generic Lambdas
Return Type Deduction
Binary Literals
Variable Templates
C++17 FEATURES
Structured Bindings
if/switch with initializers
std::optional
std::variant
std::any
Fold Expressions
Inline Variables
C++20 FEATURES
Concepts
Ranges
Coroutines
Modules
Three-way Comparison (<=>)
std::span
MEMORY MANAGEMENT
Stack vs Heap
RAII (Resource Acquisition Is Initialization)
Smart Pointers
- unique_ptr
- shared_ptr
- weak_ptr
Custom Allocators
Memory Pools
EXCEPTION HANDLING
try-catch blocks
throw keyword
Exception Classes
Standard Exceptions
noexcept specifier
Exception Safety Guarantees
FILE I/O
Stream Classes
- ifstream, ofstream, fstream
File Operations
Binary File I/O
String Streams
Formatting
MULTITHREADING
std::thread
Mutexes and Locks
Condition Variables
Atomic Operations
Thread-local Storage
Futures and Promises
async
PREPROCESSOR
Macros
#include
Header Guards
#pragma once
Conditional Compilation
ADVANCED TOPICS
Type Casting
- static_cast
- dynamic_cast
- const_cast
- reinterpret_cast
RTTI (Runtime Type Information)
Operator Overloading
Copy Elision and RVO
Perfect Forwarding
Name Mangling
Linkage
COMPILATION AND BUILD
Compilation Process
Header Files
Source Files
Linking
Build Systems
- Make
- CMake
Compiler Options
Requested a AI to provide a CPP roadmap to know CPP very thoroughly, and it has provided me this roadmap. Do you have additions? Or is this good for modern CPP?
https://redd.it/1pug6hs
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Galen Hunt's update on Rust, AI, C, C++ job post purpose
https://www.linkedin.com/posts/galenh_principal-software-engineer-coreai-microsoft-activity-7407863239289729024-WTzf
https://redd.it/1puiiyy
@r_cpp
https://www.linkedin.com/posts/galenh_principal-software-engineer-coreai-microsoft-activity-7407863239289729024-WTzf
https://redd.it/1puiiyy
@r_cpp
Linkedin
Principal Software Engineer (CoreAI) | Microsoft Careers | Galen Hunt | 31 comments
Update:
It appears my post generated far more attention than I intended... with a lot of speculative reading between the lines.
Just to clarify... Windows is *NOT* being rewritten in Rust with AI.
My team’s project is a research project. We are building…
It appears my post generated far more attention than I intended... with a lot of speculative reading between the lines.
Just to clarify... Windows is *NOT* being rewritten in Rust with AI.
My team’s project is a research project. We are building…
Multidimensional algorithms?
Hi, not sure where this should go? We will soon have submdspan in C++26, which is enough to make mdspan useful in practice.
Now the next step required is multidimensional algorithms. People are apparently against having iterators, but you can just implement them yourself.
The only standard md-algorithm is the Einstein summation notation. You can easily modify this notation to be a transformation reduction rather than a pure summation. Anyone working with mdstructures probably has that algorithm already.
But my question is: are there any plans or thoughts on md-algorithms going forward?
I mean, it's nice without it, but I am an early adaoptor and I used the reference implementation to replace an existing library. That was only possible by using submdspan and adding a few custom iterators.
https://redd.it/1pukt78
@r_cpp
Hi, not sure where this should go? We will soon have submdspan in C++26, which is enough to make mdspan useful in practice.
Now the next step required is multidimensional algorithms. People are apparently against having iterators, but you can just implement them yourself.
The only standard md-algorithm is the Einstein summation notation. You can easily modify this notation to be a transformation reduction rather than a pure summation. Anyone working with mdstructures probably has that algorithm already.
But my question is: are there any plans or thoughts on md-algorithms going forward?
I mean, it's nice without it, but I am an early adaoptor and I used the reference implementation to replace an existing library. That was only possible by using submdspan and adding a few custom iterators.
https://redd.it/1pukt78
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
C++ moving semantics
I am new to C++ coming from C
I have seen this code and it doesn't mame sense to me how an object is returned ?
like is it a pointer or what exactly.
I have limited knowledge on value types
`std::string take(std::string&& s) {
std::string x = std::move(s);
return x;
}
int main (){
const char* b {"hello, world"};
string a = take(b);}`
https://redd.it/1pukem3
@r_cpp
I am new to C++ coming from C
I have seen this code and it doesn't mame sense to me how an object is returned ?
like is it a pointer or what exactly.
I have limited knowledge on value types
`std::string take(std::string&& s) {
std::string x = std::move(s);
return x;
}
int main (){
const char* b {"hello, world"};
string a = take(b);}`
https://redd.it/1pukem3
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
The real problem of C++ - Meeting C++ 2025
Talk from Klaus Iglberger
https://www.youtube.com/watch?v=QmNkbUgADBE
https://redd.it/1pumq0y
@r_cpp
Talk from Klaus Iglberger
https://www.youtube.com/watch?v=QmNkbUgADBE
https://redd.it/1pumq0y
@r_cpp
YouTube
The real problem of C++ - Klaus Iglberger - Meeting C++ 2025
An analysis from Klaus Iglberger about what the real problem is with C++ from Meeting C++ 2025.
Slides: https://slides.meetingcpp.com
It is popular today to complain about C++’s perceived safety issues: bounds, type, initialization and lifetime safety, and…
Slides: https://slides.meetingcpp.com
It is popular today to complain about C++’s perceived safety issues: bounds, type, initialization and lifetime safety, and…
Choosing the Right C++ Containers for Performance
https://techfortalk.co.uk/2025/12/24/optimal-c-containers-for-performance-efficiency/
https://redd.it/1pup0ka
@r_cpp
https://techfortalk.co.uk/2025/12/24/optimal-c-containers-for-performance-efficiency/
https://redd.it/1pup0ka
@r_cpp
Tech For Talk
Optimal C++ Containers for Performance Efficiency
Choosing an appropriate C++ container impacts memory layout, cache efficiency, and access patterns, vital for performance. Common comparisons include std::vector, std::deque, std::array, std::list,…
Mastering Function and Class Templates in C++: A Complete Guide
https://techfortalk.co.uk/2023/02/05/beginners-guide-to-c-templates-2/
https://redd.it/1pupsrn
@r_cpp
https://techfortalk.co.uk/2023/02/05/beginners-guide-to-c-templates-2/
https://redd.it/1pupsrn
@r_cpp
Tech For Talk
Mastering Function and Class Templates in C++: A Complete Guide
The content outlines seven chapters on C++ templates, covering introductory concepts, function templates, template parameters, return types, miscellaneous aspects, class templates, and class templa…
Anyone else getting survey request from Microsoft about C++ in VSCode?
Got a survey notification for C++ experience in VSCode. Which seems like a good sign Microsoft might actually be interested in improving support for it.
Anyone else getting these or is this just a random thing they do every once in a while?
https://redd.it/1purcv5
@r_cpp
Got a survey notification for C++ experience in VSCode. Which seems like a good sign Microsoft might actually be interested in improving support for it.
Anyone else getting these or is this just a random thing they do every once in a while?
https://redd.it/1purcv5
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Course program for 1st year students - no experience with OOP
Hi guys,
I'll be teaching relative newbies OOP in C++. They know some C++ but no OOP. Each lecture will be 3 hours. What do you think about the curriculum?
* **Introduction to OOP.** Review of pointers, references, and memory types in C++. Passing by value/reference. Procedural style vs. OOP – what OOP improves. Basic principles of OOP. Classes and objects at a high level. Structures in C++. Comparison of the basic principles with Java. Examples.
* **Abstraction and Encapsulation.** Access modifiers. Abstraction. Const classes and member functions. `mutable`. Streams and file input/output.
* **Constructors and Destructor.** The `this` pointer. Invocation of constructors and destructors. Converting constructors. Constructor and destructor calls when creating arrays (static and dynamic). The RAII principle.
* **Copy constructor and assignment operator (**`operator=`**).** Separate compilation. Preprocessor. Composition and aggregation. Examples – the `Student` class.
* **Move semantics** – benefits, lvalue, rvalue, move constructor/assignment operator, `std::move`. Example of a string class with move semantics (C++11). Arrays of pointers to objects.
* **Rule of Five and Rule of Zero.** Dynamic memory in classes. `default` / `delete` for special member functions (C++11). Example of a student class with a name (arbitrary length) and an array of grades (arbitrary length).
* **Operator overloading.** Friend classes and functions. Defaulted comparison operators and `<=>` (C++20). Example implementation of a complex number and an `Nvector`.
* **Error handling.** Static data members. Exceptions. Exception handling. Exception hierarchies and examples. Exceptions in constructors and destructors. Levels of exception safety. Modern approach – `std::expected` (C++23). Example of a class that counts its instances.
* **Relationships between objects.** Association. Dependencies. Ownership. Design guidelines.
* **Inheritance.** Types of inheritance. Function parameters (pointers and references). Constructors and destructors in inheritance. Copying in inheritance. Move semantics in inheritance. Example with a person, student, and teacher.
* **The** `virtual` **keyword.** Static and dynamic binding. Virtual functions. Keywords `override`, `final`. Virtual tables. Polymorphism – runtime and compile-time. Example.
* **Abstract classes and interfaces.** Pure virtual functions. Object slicing, type casts. Type erasure (`std::function`, C++11). Comparison with Java.
* **Multiple inheritance.** Diamond problem. Collections of objects in a polymorphic hierarchy. Copying and deletion. Example with the `Student` class.
* **Templates.** Required functions in a template class/template function. Template specializations. Examples of template classes/functions from the standard library. Smart pointers. Usage and idea of `shared_ptr`, `weak_ptr`, `unique_ptr` (C++11/14). Example of a stack (with template capacity) and a queue (with a `resize` function).
* **Design patterns.** SOLID principles. Pattern examples – Singleton, Factory, Prototype, Composite, Flyweight, Iterator, Command, Visitor, PIMPL – examples.
https://redd.it/1puugre
@r_cpp
Hi guys,
I'll be teaching relative newbies OOP in C++. They know some C++ but no OOP. Each lecture will be 3 hours. What do you think about the curriculum?
* **Introduction to OOP.** Review of pointers, references, and memory types in C++. Passing by value/reference. Procedural style vs. OOP – what OOP improves. Basic principles of OOP. Classes and objects at a high level. Structures in C++. Comparison of the basic principles with Java. Examples.
* **Abstraction and Encapsulation.** Access modifiers. Abstraction. Const classes and member functions. `mutable`. Streams and file input/output.
* **Constructors and Destructor.** The `this` pointer. Invocation of constructors and destructors. Converting constructors. Constructor and destructor calls when creating arrays (static and dynamic). The RAII principle.
* **Copy constructor and assignment operator (**`operator=`**).** Separate compilation. Preprocessor. Composition and aggregation. Examples – the `Student` class.
* **Move semantics** – benefits, lvalue, rvalue, move constructor/assignment operator, `std::move`. Example of a string class with move semantics (C++11). Arrays of pointers to objects.
* **Rule of Five and Rule of Zero.** Dynamic memory in classes. `default` / `delete` for special member functions (C++11). Example of a student class with a name (arbitrary length) and an array of grades (arbitrary length).
* **Operator overloading.** Friend classes and functions. Defaulted comparison operators and `<=>` (C++20). Example implementation of a complex number and an `Nvector`.
* **Error handling.** Static data members. Exceptions. Exception handling. Exception hierarchies and examples. Exceptions in constructors and destructors. Levels of exception safety. Modern approach – `std::expected` (C++23). Example of a class that counts its instances.
* **Relationships between objects.** Association. Dependencies. Ownership. Design guidelines.
* **Inheritance.** Types of inheritance. Function parameters (pointers and references). Constructors and destructors in inheritance. Copying in inheritance. Move semantics in inheritance. Example with a person, student, and teacher.
* **The** `virtual` **keyword.** Static and dynamic binding. Virtual functions. Keywords `override`, `final`. Virtual tables. Polymorphism – runtime and compile-time. Example.
* **Abstract classes and interfaces.** Pure virtual functions. Object slicing, type casts. Type erasure (`std::function`, C++11). Comparison with Java.
* **Multiple inheritance.** Diamond problem. Collections of objects in a polymorphic hierarchy. Copying and deletion. Example with the `Student` class.
* **Templates.** Required functions in a template class/template function. Template specializations. Examples of template classes/functions from the standard library. Smart pointers. Usage and idea of `shared_ptr`, `weak_ptr`, `unique_ptr` (C++11/14). Example of a stack (with template capacity) and a queue (with a `resize` function).
* **Design patterns.** SOLID principles. Pattern examples – Singleton, Factory, Prototype, Composite, Flyweight, Iterator, Command, Visitor, PIMPL – examples.
https://redd.it/1puugre
@r_cpp
Reddit
From the cpp community on Reddit
Explore this post and more from the cpp community
Gstreamer: RTSP pipeline is not being freed
Hi everyone!
Sorry for posting it here and not in r/gstreamer, I'm waiting to be accepted but this issue is making me crazy.
I'm working on a C++ program which uses gstreamer to get a video from mediamtx via rtsp and send it to other targets via rtp udp, If mediamtx stops the video stream, my program should be trying to read it until the stream is available again. Also, this programs is used for multiple video streams, so every pipeline is run on a separated thread.
When the mediamtx video source is not available, my program enters on a loop where it resets the pipeline every n seconds, so when the video is available again, my program read it again and send to the other targets.
The issue is that every time the video is avaiable again, the pipeline allocates memory (for x264enc I think) but it doesn't frees the memory used before, so after a while between some video restarts, the memory allocated grows a lot, the only way to free it is restarting my program.
I tried to use valgrind, LSAN, GST_TRACER and `gst_deinit()` at the end of my program to check for any memory leak, but there is nothing related to the pipeline, also when the thread that is running the stream is stopped, I'm sure that the pipeline is removed with this:
```cpp
struct GstDeleter
{
void operator()(GstElement *ptr) const
{
if (ptr) gst_object_unref(ptr);
}
};
```
I checked the refcount before the unref, and is 1, so its supposed that the pipeline and the other elements (source, encoders, etc.) will be deleted.
The restart section is the following:
```cpp
void RtspStream::RestartConnection()
{
...
std::cout << Format("Video stream lost for %ld seconds, waiting 3s to reconnect\n", seconds_elapsed);
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << "Reconnecting..." << std::endl;
GstState state, pending;
gst_element_set_state(pipeline.get(), GST_STATE_NULL);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
}
```
The pipeline is the following:
```cpp
pipeline = std::unique_ptr<GstElement, GstDeleter>(gst_pipeline_new(pipelineName.c_str()));
const auto pipelineSource = gst_element_factory_make("rtspsrc", "source");
const auto decodebin = gst_element_factory_make("decodebin", "decoder");
const auto videoconvert = gst_element_factory_make("videoconvert", "videoconvert");
const auto x264enc = gst_element_factory_make("x264enc", "x264enc");
const auto h264parse = gst_element_factory_make("h264parse", "h264parse");
const auto rtph264pay = gst_element_factory_make("rtph264pay", "rtph264pay");
const auto tee = gst_element_factory_make("tee", "tee");
const auto fakeQueue = gst_element_factory_make("queue", "fake_queue");
const auto fakesink = gst_element_factory_make("fakesink", "fakesink");
if (!pipeline || !pipelineSource || !decodebin || !videoconvert || !x264enc || !h264parse || !rtph264pay || !tee || !fakeQueue || !fakesink)
{
std::cerr << "Failed to create elements" << std::endl;
return;
}
g_object_set(source, "onvif-rate-control", 0, "location", src.url.value().c_str(), "latency", 0u, nullptr);
gst_util_set_object_arg(G_OBJECT(source), "protocols", "tcp");
gst_util_set_object_arg(G_OBJECT(x264enc), "tune", "zerolatency");
gst_util_set_object_arg(G_OBJECT(x264enc), "speed-preset", "ultrafast");
g_object_set(x264enc, "key-int-max", 15u, nullptr);
g_object_set(rtph264pay, "config-interval", 1, "pt", 96, nullptr);
gst_bin_add_many(GST_BIN(pipeline.get()), pipelineSource, decodebin, videoconvert, x264enc, h264parse, rtph264pay, tee, fakeQueue, fakesink, nullptr);
// Dynamic pad linking for source -> decodebin
// ReSharper disable once CppParameterMayBeConst
g_signal_connect(pipelineSource, "pad-added", G_CALLBACK(+[]([[maybe_unused]] GstElement *src, GstPad *src_pad, gpointer data)
{
const auto decodebin_ref =
Hi everyone!
Sorry for posting it here and not in r/gstreamer, I'm waiting to be accepted but this issue is making me crazy.
I'm working on a C++ program which uses gstreamer to get a video from mediamtx via rtsp and send it to other targets via rtp udp, If mediamtx stops the video stream, my program should be trying to read it until the stream is available again. Also, this programs is used for multiple video streams, so every pipeline is run on a separated thread.
When the mediamtx video source is not available, my program enters on a loop where it resets the pipeline every n seconds, so when the video is available again, my program read it again and send to the other targets.
The issue is that every time the video is avaiable again, the pipeline allocates memory (for x264enc I think) but it doesn't frees the memory used before, so after a while between some video restarts, the memory allocated grows a lot, the only way to free it is restarting my program.
I tried to use valgrind, LSAN, GST_TRACER and `gst_deinit()` at the end of my program to check for any memory leak, but there is nothing related to the pipeline, also when the thread that is running the stream is stopped, I'm sure that the pipeline is removed with this:
```cpp
struct GstDeleter
{
void operator()(GstElement *ptr) const
{
if (ptr) gst_object_unref(ptr);
}
};
```
I checked the refcount before the unref, and is 1, so its supposed that the pipeline and the other elements (source, encoders, etc.) will be deleted.
The restart section is the following:
```cpp
void RtspStream::RestartConnection()
{
...
std::cout << Format("Video stream lost for %ld seconds, waiting 3s to reconnect\n", seconds_elapsed);
std::this_thread::sleep_for(std::chrono::seconds(3));
std::cout << "Reconnecting..." << std::endl;
GstState state, pending;
gst_element_set_state(pipeline.get(), GST_STATE_NULL);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
gst_element_set_state(pipeline.get(), GST_STATE_PLAYING);
gst_element_get_state(pipeline.get(), &state, &pending, GST_CLOCK_TIME_NONE);
}
```
The pipeline is the following:
```cpp
pipeline = std::unique_ptr<GstElement, GstDeleter>(gst_pipeline_new(pipelineName.c_str()));
const auto pipelineSource = gst_element_factory_make("rtspsrc", "source");
const auto decodebin = gst_element_factory_make("decodebin", "decoder");
const auto videoconvert = gst_element_factory_make("videoconvert", "videoconvert");
const auto x264enc = gst_element_factory_make("x264enc", "x264enc");
const auto h264parse = gst_element_factory_make("h264parse", "h264parse");
const auto rtph264pay = gst_element_factory_make("rtph264pay", "rtph264pay");
const auto tee = gst_element_factory_make("tee", "tee");
const auto fakeQueue = gst_element_factory_make("queue", "fake_queue");
const auto fakesink = gst_element_factory_make("fakesink", "fakesink");
if (!pipeline || !pipelineSource || !decodebin || !videoconvert || !x264enc || !h264parse || !rtph264pay || !tee || !fakeQueue || !fakesink)
{
std::cerr << "Failed to create elements" << std::endl;
return;
}
g_object_set(source, "onvif-rate-control", 0, "location", src.url.value().c_str(), "latency", 0u, nullptr);
gst_util_set_object_arg(G_OBJECT(source), "protocols", "tcp");
gst_util_set_object_arg(G_OBJECT(x264enc), "tune", "zerolatency");
gst_util_set_object_arg(G_OBJECT(x264enc), "speed-preset", "ultrafast");
g_object_set(x264enc, "key-int-max", 15u, nullptr);
g_object_set(rtph264pay, "config-interval", 1, "pt", 96, nullptr);
gst_bin_add_many(GST_BIN(pipeline.get()), pipelineSource, decodebin, videoconvert, x264enc, h264parse, rtph264pay, tee, fakeQueue, fakesink, nullptr);
// Dynamic pad linking for source -> decodebin
// ReSharper disable once CppParameterMayBeConst
g_signal_connect(pipelineSource, "pad-added", G_CALLBACK(+[]([[maybe_unused]] GstElement *src, GstPad *src_pad, gpointer data)
{
const auto decodebin_ref =