Leanpub Header

Skip to main content

Mastering Modern C++23

A Practical Guide to Real-World Features, Patterns, and Best Practices

Mastering Modern C++23
This book is 100% completeLast updated on 2026-10-16

Mastering Modern C++23 is a practical guide to the latest C++ standard, helping intermediate and advanced developers confidently adopt its most important language and library features. With clear explanations, production-ready examples, and real-world best practices, you'll write safer, more expressive, and high-performance C++ code.

Minimum price

$25.00

$35.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
289
Pages
About

About

About the Book

This book takes intermediate to advanced C++ developers on a comprehensive journey through the C++23 standard (ISO/IEC 14882:2024). You will learn every significant language and library feature added in this release, understand the design rationale behind each decision, and see how to apply them effectively in production software. From error handling with `std::expected` to formatted output with `std::print`, from multidimensional data access with `std::mdspan` to coroutine-based generators, this guide covers the tools that make modern C++ safer, more expressive, and more maintainable without sacrificing performance. Each chapter includes production-quality code examples, performance considerations, migration strategies from earlier standards, and practical exercises to solidify your understanding.

Bundle

Bundles that include this book

Author

About the Author

Steve Publications

Steve is a technology professional with over 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. He specializes in analyzing complex systems, identifying weaknesses and improving security.

Beyond his professional work, Steve collaborates with researchers and industry experts to create practical technical books covering software development, cybersecurity, cloud computing, DevOps, AI and enterprise technologies. His goal is to help IT professionals, students and enthusiasts develop practical skills through clear explanations, real-world examples and hands-on exercises.

At Steve Publications, we use AI to assist with translation, proofreading and editing but not to replace the research, technical expertise or hands-on experience behind our books. Some authors publish under pseudonyms for privacy or professional reasons.

Every book is written, reviewed and maintained by experienced professionals, supported by a private community of over 420 engineers and researchers. We prioritize technical accuracy, practical value and regularly updated content over mass-produced AI-generated text.

We welcome experienced professionals interested in writing or reviewing books, especially in specialized and emerging technology fields. If you'd like to contribute, contact us with your area of expertise.

We stand behind our work. If a book doesn't meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

A Comprehensive Guide from Fundamentals to Advanced Modern C++

Introduction: The Journey from Beginner to C++23 Mastery

Part I: Foundations of C++

Chapter 1: What Is C++ and Why Does It Matter?

  1. A Brief History: From C with Classes to C++23
  2. Where Is C++ Used?
  3. What Makes C++ Different?
  4. The Modern C++ Philosophy
  5. Learning Path for This Book
  6. Exercises

Chapter 2: Your First C++ Program: Tools and Compilation

  1. Installing a C++ Compiler
  2. How C++ Programs Are Built
  3. Writing Your First Program
  4. Compiling and Running Your Program
  5. Build Systems: Introducing CMake
  6. Editors and IDEs
  7. Understanding Compiler Errors
  8. Exercises

Chapter 3: Variables, Types and Operators

  1. Fundamental Data Types
  2. Declaring and Initializing Variables
  3. const and constexpr: Immutable Values
  4. References vs Pointers
  5. Understanding Type Size and sizeof
  6. Operators
  7. Exercises

Chapter 4: Control Flow and Functions

  1. Conditional Execution: if and switch
  2. Loops
  3. Early Return: A Modern C++ Style
  4. Functions
  5. Namespaces: Organizing Code
  6. Exercises

Chapter 5: Classes, Objects and Memory Management

  1. Defining Classes
  2. Access Control: public, private, protected
  3. Constructors and Initialization
  4. The Rule of Zero, Three and Five
  5. Stack vs Heap Memory
  6. Smart Pointers: RAII and Automatic Memory Management
  7. Move Semantics: Efficient Resource Transfer
  8. Exercises

Chapter 6: The C++ Standard Library Essentials

  1. Containers: Storing Collections of Data
  2. Algorithms: Operating on Collections
  3. Iterators: Traversing Containers
  4. Utility Types: std::optional, std::variant, std::pair
  5. File I/O Basics
  6. Exercises

Part II: Modern C++ Foundations (C++11 to C++20)

Chapter 7: Modern C++ Foundations (C++11 through C++20)

  1. C++11: The Great Modernization (2011)
  2. C++14: Refinements (2014)
  3. C++17: Practical Improvements (2017)
  4. C++20: The Paradigm Shift (2020)
  5. Exercises

Part III: Mastering C++23

Chapter 8: The C++23 Landscape

  1. The Standardization Process: From Proposal to Published Standard
  2. What Changed in C++23: A Taxonomy of Improvements
  3. Compiler Support: The Reality of Adoption
  4. Feature Test Macros: Detecting C++23 Support
  5. Setting Up Your Development Environment
  6. How to Read This Book
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Chapter 9: Core Language Enhancements I: Syntax and Semantics

  1. Explicit Object Parameters: deducing this and Beyond
  2. Multidimensional Subscripts: A Natural Syntax for Multi-D Data
  3. constexpr Enhancements: More Compile-Time Power
  4. Attribute Refinements and the [[assume]] Attribute
  5. Template Parameter Improvements and Class Template Argument Deduction
  6. Key Takeaways
  7. Exercises
  8. Challenge Project

Chapter 10: Core Language Enhancements II: Control Flow and Expressions

  1. Constexpr Control Flow: if consteval
  2. Preprocessor Directives: #elifdef, #elifndef and #warning
  3. Literal Suffixes for size_t: zu and uz
  4. Extending Temporary Lifetime in Range-Based For Loops
  5. Static Call and Subscript Operators
  6. Simplifying Implicit Move
  7. Labels at the End of Compound Statements
  8. Key Takeaways
  9. Exercises
  10. Challenge Project

Chapter 11: The std::expected Library

  1. The Problem with Exceptions: When They Are Not the Right Tool
  2. Design Rationale: Why expected Instead of optional?
  3. API Deep Dive: Constructors, Accessors and Operations
  4. Comparison with Boost.Expected and Other Approaches
  5. Performance Characteristics and Memory Layout
  6. Migration Strategies from Exception-Based Code
  7. Real-World Use Cases in Production Systems
  8. Key Takeaways
  9. Exercises
  10. Challenge Project

Chapter 12: The Formatting Library: std::print and Beyond

  1. The Formatting Problem: From printf to Modern C++
  2. std::print and std::println: Immediate Output
  3. format_string: Compile-Time Safe Formatting
  4. Custom Formatters: Extending the System
  5. Performance Characteristics
  6. Migration Strategies from Existing Code
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Chapter 13: Ranges and Iterators in C++23

  1. Ranges in C++20: A Quick Recap
  2. New Range Adaptors: chunk_by, slide and More
  3. Improvements to Existing Adaptors
  4. Range Algorithms Enhancements
  5. The ranges::to<> Conversion Function
  6. Integration with Concepts and Constraints
  7. Performance Considerations and Benchmarking
  8. Real-World Usage Patterns
  9. Key Takeaways
  10. Exercises
  11. Challenge Project

Chapter 14: Compile-Time Programming and Metaprogramming

  1. The constexpr Revolution: From C++11 to C++23
  2. Expanded constexpr Capabilities in C++23
  3. consteval and Compile-Time Function Execution
  4. Unknown Pointers in Constant Expressions
  5. std::source_location: Better Diagnostics at Compile Time
  6. Template Metaprogramming Patterns with C++23
  7. Performance Implications of Compile-Time Computation
  8. Key Takeaways
  9. Exercises
  10. Challenge Project

Chapter 15: Coroutines and std::generator

  1. What Are Coroutines?
  2. std::generator: The C++23 Coroutine Type
  3. Practical Use Cases for Generators
  4. Understanding Generator Type Parameters
  5. Exercises

Chapter 16: Concurrency and Parallelism Improvements

  1. Concurrency Foundations
  2. New Synchronization Features
  3. C++23 Concurrency Refinements
  4. Parallel Algorithms Enhancements
  5. jthread and stop_token Improvements
  6. Thread Safety Best Practices and Pitfalls
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Chapter 17: Containers, Iterators and Algorithms

  1. Container Improvements in C++23
  2. New Containers: flat_map and flat_set
  3. Iterators and Algorithms Enhancements
  4. Performance Characteristics
  5. Migration Strategies
  6. Key Takeaways
  7. Exercises
  8. Challenge Project

Chapter 18: Modules, Templates and the Type System

  1. The Module System: Status and Best Practices in C++23
  2. Template Constraints and Concepts Refinements
  3. New Type Traits for Modern Programming
  4. std::move_only_function: Type-Erased Move-Only Callables
  5. Impact on Build Times and Compilation Strategy
  6. Migration Strategies from Header-Based Libraries
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Chapter 19: Testing, Debugging and Tooling

  1. Testing Strategies for Modern C++ Code
  2. Debugging Techniques: constexpr, Templates and More
  3. Static Analysis Tools and C++23 Support
  4. Profiling and Benchmarking Modern C++
  5. IDE Support and Language Server Improvements
  6. Continuous Integration and Deployment with C++23
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Chapter 20: Production Patterns and Best Practices

  1. Design Patterns with Modern C++ Features
  2. Error Handling Strategies: expected, Exceptions, or Both?
  3. Performance Optimization Techniques
  4. Code Organization and Architecture Decisions
  5. Migration Strategies for Large Codebases
  6. What’s Coming Next: C++26 Preview
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Conclusion: The Journey Continues

References

Appendix A: C++23 Feature Reference

  1. Key Library Additions
  2. Range Adaptors
  3. Range Algorithms
  4. String Improvements
  5. Other Library Features

Appendix B: Compiler Compatibility Matrix

Appendix C: Migration Checklist

  1. Error Handling
  2. Formatted Output
  3. Ranges
  4. Containers
  5. Compile-Time Programming

Appendix D: Coding Standards for Modern C++23

Appendix E: Common C++23 Interview Questions

Appendix F: Glossary

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.)

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