C++ Fundamentals
Core C++ resource management, templates, and object-lifetime concepts.
Key Concepts
+ Add ConceptC++ Cast Operators
C++ Cast Operators
C++ named casts make the kind of conversion explicit. Each has a narrow purpose: compile-time conversions, checked polymorphic downcasts, constness changes, or low-level representation conversions.
C++ Const Correctness
C++ Const Correctness
Const correctness documents whether an operation may modify an object and lets the compiler enforce that contract. It applies to objects, references, pointers, member functions, and overload selection.
C++ Containers and Algorithms
C++ Containers and Algorithms
The C++ standard library separates data structures from algorithms. Choosing a container depends on ownership, access pattern, invalidation behavior, and complexity; algorithms operate on iterator ranges rather than particular container types.
C++ Exception Safety
C++ Exception Safety
Exception-safe C++ code uses RAII so resources are released during stack unwinding and defines what state remains after an operation throws. Common guarantees are no-throw, strong, and basic.
C++ Initialization Forms
C++ Initialization Forms
C++ has several initialization forms with different overload resolution and conversion behavior. List initialization using braces rejects narrowing conversions, making it a useful default when that stricter behavior is desired.
C++ Memory Model and Data Races
C++ Memory Model and Data Races
The C++ memory model defines how threads observe reads and writes. A data race on non-atomic memory is undefined behavior; mutexes and atomics create the synchronization needed to safely communicate between threads.
C++ Move Semantics
C++ Move Semantics
Move semantics transfer resources from an expiring object instead of making an expensive copy. std::move enables a move operation but does not itself move or destroy an object.
C++ Object Lifetime
C++ Object Lifetime
An object’s lifetime begins when its initialization is complete and ends when its destructor starts or its storage is released, depending on the object. Pointers and references do not extend lifetime unless an owning mechanism does so explicitly.
C++ Ranges and Views
C++ Ranges and Views
C++ ranges express operations over sequences, and views adapt a range lazily without usually owning or materializing a new collection. Views inherit lifetime and invalidation constraints from their underlying range.
C++ Smart Pointers
C++ Smart Pointers
Smart pointers express ownership of heap-allocated objects. std::unique_ptr provides exclusive ownership, std::shared_ptr provides reference-counted ownership, and std::weak_ptr observes a shared object without extending its lifetime.
C++ Templates and Concepts
C++ Templates and Concepts
Templates generate type-specific code from a generic definition. C++ concepts constrain template arguments and make generic API requirements explicit and diagnosable.
C++ Translation Units and ODR
C++ Translation Units and ODR
C++ source files are compiled separately into translation units and later linked. The One Definition Rule constrains which declarations and definitions may appear across those units and prevents inconsistent definitions of the same entity.
C++ Undefined Behavior
C++ Undefined Behavior
Undefined behavior occurs when a program violates a rule for which the C++ standard imposes no requirements. It is not a reliable runtime error: compilers may optimize based on the assumption that undefined behavior never occurs.
C++ Value Categories and Forwarding
C++ Value Categories and Forwarding
Value categories describe expression identity and lifetime. Forwarding references and std::forward let generic wrappers preserve whether an argument was an lvalue or rvalue when passing it onward.
C++ Vocabulary Types
C++ Vocabulary Types
Standard vocabulary types such as std::optional, std::variant, and std::expected make absence, alternative states, and recoverable errors explicit in function signatures.