Leanpub Header

Skip to main content

The Complete C++23 Guide: From Beginner to Advanced

From First Program to Expert-Level Systems Programming

This book is 100% completeLast updated on 2026-07-24

Learn modern C++23 from the ground up with clear explanations and complete, compilable examples. From your first program to advanced topics like concurrency, metaprogramming and performance optimization, this book gives you the skills to write fast, reliable and professional-quality C++ software.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
387
Pages
About

About

About the Book

This book takes you from absolute beginner to expert in C++23, the modern standard that combines decades of language evolution with cutting-edge features. You will learn everything from writing your first program through advanced topics like coroutines, metaprogramming, lock-free concurrency, and performance optimization. Every concept is explained clearly with complete, compilable code examples that work on GCC, Clang, and MSVC. Whether you are new to programming or an experienced developer transitioning to modern C++, this book provides the knowledge and practical skills needed to write professional-quality systems software.

Author

About the Author

Steve Publications

Steve is a technology professional with more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 400 engineers and researchers from Ukraine, Belarus and Russia. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

Contents

Table of Contents

From First Program to Expert-Level Systems Programming

Introduction: Why C++23 Matters

  1. The World Runs on C++
  2. What Is C++23?
  3. Zero-Cost Abstractions and Systems Programming
  4. Who Should Read This Book
  5. How to Use This Book

Chapter 1: The Evolution of C++

  1. Before C++: BCPL, B, and C
  2. C with Classes (1979–1983)
  3. The First Standard: C++98
  4. C++03 and C++11: Modernization Begins
  5. C++14, C++17: Refinement and Growth
  6. C++20: A Quantum Leap
  7. C++23: Polishing the Modern Era
  8. The C++ Standardization Process
  9. Looking Forward: C++26 and Beyond
  10. C++ Design Philosophy: Key Principles
  11. Why These Principles Matter for You

Chapter 2: Setting Up Your Development Environment

  1. Compilers: GCC, Clang, and MSVC
  2. Installing on Linux
  3. Installing on macOS
  4. Installing on Windows
  5. Editors and IDEs
  6. Your First Compilation
  7. Using CMake for Build Management
  8. Verifying Your Setup
  9. Essential Compiler Flags Explained
  10. CMake Best Practices
  11. Setting Up a Development Workflow

Chapter 3: Program Structure and Fundamental Syntax

  1. Anatomy of a C++ Program
  2. How the Compiler Processes Your Code
  3. The Preprocessor and Directives
  4. The Main Function
  5. Statements and Expressions
  6. Comments and Documentation Style
  7. Whitespace and Formatting Conventions
  8. Common Beginner Mistakes

Chapter 4: Data Types, Variables, and Operators

  1. Fundamental Data Types
  2. Variables and Initialization
  3. Type Modifiers and Qualifiers
  4. Arithmetic and Bitwise Operators
  5. Relational and Logical Operators
  6. Assignment and Compound Operators
  7. Operator Precedence and Associativity
  8. Type Conversion and Casting

Chapter 5: Control Flow

  1. Conditional Execution with if and else
  2. The switch Statement and Pattern Matching
  3. While and Do-While Loops
  4. For Loops and Range-Based For
  5. Jump Statements
  6. Structuring Complex Logic
  7. Control Flow Best Practices

Chapter 6: Functions

  1. Defining and Calling Functions
  2. Parameters and Arguments
  3. Return Values and Multiple Results
  4. Function Overloading
  5. Inline Functions and Linkage
  6. Default Arguments and Parameter Packs
  7. Function Pointers and Callables
  8. Designing Clean Function Interfaces

Chapter 7: Arrays, Strings, and Basic Containers

  1. Raw Arrays and Their Limitations
  2. std::array for Fixed-Size Collections
  3. std::vector for Dynamic Arrays
  4. std::string and Text Handling
  5. String Literals and Character Types
  6. Container Fundamentals
  7. Choosing the Right Container

Chapter 8: Namespaces, Modules, and Code Organization

  1. Why Namespaces Exist
  2. Using and Creating Namespaces
  3. Inline and Anonymous Namespaces
  4. The Module System
  5. Modules Versus Headers
  6. Organizing Large Projects
  7. Migration Strategies for Codebases

Chapter 9: Classes and Object-Oriented Programming

  1. Defining Classes and Creating Objects
  2. Constructors and Destructors
  3. Access Control and Encapsulation
  4. The this Pointer and Const Correctness
  5. Static Members and Class Invariants
  6. Friend Functions and Classes
  7. Inheritance and Code Reuse
  8. Polymorphism and Virtual Functions

Chapter 10: Advanced OOP and Design Patterns

  1. The Rule of Zero, Three, Five, and Six
  2. Multiple Inheritance and Diamond Problems
  3. Virtual Destructors and Polymorphic Cleanup
  4. Composition Versus Inheritance
  5. Common Design Patterns in C++23
  6. CRTP and Static Polymorphism
  7. Interface Design Best Practices

Chapter 11: Templates and Generic Programming

  1. Why Generic Programming Matters
  2. Function Templates
  3. Class Templates
  4. Template Argument Deduction
  5. Explicit Specialization
  6. Partial Specialization
  7. Designing Generic Code

Chapter 12: Concepts and Constraints

  1. The Problem Templates Created
  2. Introducing Concepts
  3. Writing Your Own Concepts
  4. Requires Clauses and Constraints
  5. Standard Library Concepts
  6. Concepts Versus SFINAE
  7. Designing Type-Safe Generic APIs
  8. Understanding Constraint Satisfaction
  9. Error Messages: Concepts Versus SFINAE
  10. Advanced Constraint Patterns
  11. When Not to Use Concepts

Chapter 13: Compile-Time Programming with constexpr, consteval, and constinit

  1. The Power of Compile-Time Execution
  2. constexpr Functions and Variables
  3. consteval and Immediate Functions
  4. constinit for Static Initialization
  5. if constexpr for Conditional Compilation
  6. Compile-Time Data Structures
  7. Practical Compile-Time Techniques

Chapter 14: Lambdas and Callable Objects

  1. Anonymous Functions with Lambdas
  2. Capture Lists and Environments
  3. Generic Lambdas with auto
  4. Mutable and Constexpr Lambdas
  5. Lambdas Versus Function Objects
  6. Using Lambdas in Standard Library Algorithms
  7. Advanced Lambda Patterns

Chapter 15: Memory Management, RAII, and Smart Pointers

  1. How C++ Manages Memory
  2. Stack Allocation Versus Heap Allocation
  3. The RAII Principle
  4. std::unique_ptr for Exclusive Ownership
  5. std::shared_ptr for Shared Ownership
  6. std::weak_ptr and Breaking Cycles
  7. Custom Deleters and Resource Management

Chapter 16: Move Semantics and Perfect Forwarding

  1. Lvalues, Rvalues, and Value Categories
  2. Rvalue References Explained
  3. Move Constructors and Move Assignment
  4. std::move and Its Semantics
  5. Perfect Forwarding with std::forward
  6. Designing Move-Aware Classes
  7. Performance Impact of Move Semantics
  8. When Moves Do Not Help
  9. Common Move Semantics Mistakes
  10. Move Semantics and Containers
  11. C++23 Simplified Implicit Move

Chapter 17: Exception Handling

  1. Why Exceptions Exist
  2. try, catch, and throw
  3. The Standard Exception Hierarchy
  4. Custom Exception Classes
  5. noexcept and Exception Specifications
  6. Exception Safety Guarantees
  7. When to Use (and Avoid) Exceptions

Chapter 18: The Ranges Library

  1. What Are Ranges?
  2. Range Concepts and Requirements
  3. Views and Lazy Evaluation
  4. Range Adaptors and Pipelines
  5. Range Algorithms
  6. Actions and Eager Operations
  7. Practical Range-Based Code
  8. Common Range Pitfalls and How to Avoid Them
  9. Advanced Range Patterns

Chapter 19: Coroutines

  1. What Are Coroutines?
  2. Coroutine Anatomy: Promise and Frame
  3. Writing Your First Generator
  4. Tasks and Async-Await Patterns
  5. Structured Concurrency Foundations
  6. C++23 Coroutine Enhancements
  7. Practical Coroutine Applications
  8. Understanding Awaitables in Depth
  9. Error Handling in Coroutines
  10. Performance Considerations
  11. Compiler Support for std::generator
  12. When to Use (and Avoid) Coroutines

Chapter 20: Concurrency and Multithreading

  1. Why Concurrency Matters
  2. Creating and Managing Threads
  3. Shared State and Data Races
  4. Mutexes and Locking Strategies
  5. Condition Variables and Synchronization
  6. Atomic Operations and Memory Ordering
  7. Thread-Local Storage
  8. The C++ Memory Model

Chapter 21: Advanced Concurrency Patterns

  1. Lock-Free Data Structures
  2. Concurrent Queues and Containers
  3. Executors and Scheduled Execution
  4. Parallel STL Algorithms
  5. Future-Based Asynchronous Programming
  6. Avoiding Deadlocks and Priority Inversion

Chapter 22: Metaprogramming and Template Techniques

  1. Template Metaprogramming Fundamentals
  2. Type Traits and Inspection
  3. Variadic Templates and Parameter Packs
  4. Fold Expressions
  5. SFINAE and Modern Alternatives
  6. Constexpr Metaprogramming
  7. Looking Ahead to Reflection

Chapter 23: Performance Optimization

  1. Measuring Before Optimizing
  2. Understanding Modern CPU Architecture
  3. Cache-Friendly Data Layouts
  4. Branch Prediction and Control Flow
  5. Inlining and Compilation Optimization
  6. Data-Oriented Design Principles
  7. Benchmarking with Rigor

Chapter 24: Debugging, Testing, and Quality Assurance

  1. Using GDB and LLDB Effectively
  2. Compiler Sanitizers for Bug Detection
  3. Static Analysis Tools
  4. Unit Testing with Modern Frameworks
  5. Property-Based and Fuzz Testing
  6. Continuous Integration for C++
  7. Code Review and Quality Standards

Chapter 25: The C++23 Standard Library — Containers and Algorithms

  1. Sequence Containers in Depth
  2. Associative Containers in Depth
  3. Unordered Containers in Depth
  4. Container Adapters
  5. Iterator Categories and Concepts
  6. The Algorithm Library
  7. Custom Allocators
  8. Container Selection Guide
  9. Algorithm Complexity Reference
  10. Modern Container Patterns

Chapter 26: The C++23 Standard Library — Utilities and Beyond

  1. Optional Values with std::optional
  2. Type-Safe Unions with std::variant
  3. Type-Erased Storage with std::any
  4. Error Handling with std::expected
  5. Safe Array Views with std::span and mdspan
  6. Formatting with std::format
  7. Diagnostics: source_location and stacktrace
  8. Filesystem Operations
  9. Time and Duration with chrono
  10. Regular Expressions
  11. Numerics and Random Number Generation
  12. Advanced std::expected Patterns
  13. Advanced std::format Usage
  14. C++20/23 Chrono and Calendar
  15. Regular Expressions Best Practices

Chapter 27: Interoperability with C

  1. Why C Interop Still Matters
  2. extern “C” and Name Mangling
  3. Compatible Data Layouts
  4. String and Pointer Interop
  5. Calling Conventions and ABI
  6. Wrapping C Libraries for C++ Use
  7. Embedding C++ in C Projects

Chapter 28: Migration from Earlier C++ Standards

  1. Assessing Your Current Codebase
  2. From C++98/03 to Modern C++
  3. From C++11/14 to C++23
  4. From C++17/20 to C++23
  5. Deprecated and Removed Features
  6. Automated Migration Tools
  7. Incremental Adoption Strategies

Conclusion: The Future of C++

  1. C++26 and the Road Ahead
  2. Ongoing Standardization Efforts
  3. The C++ Community and Governance
  4. Learning Resources and Communities
  5. Building a Career with C++
  6. Final Thoughts

References

Appendix: C++23 Compiler Support Reference

  1. GCC (GNU Compiler Collection)
  2. Clang (LLVM)
  3. MSVC (Microsoft Visual C++)
  4. Feature-Specific Support Summary
  5. Cross-Platform Development Tips
  6. Checking Your Compiler’s C++23 Support

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub