Leanpub Header

Skip to main content

Mastering Modern C++23

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

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

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

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
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 T. Publications

Steve T. is a technology professional with over 20 years of experience spanning software development, server infrastructure operations, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has built extensive expertise in designing, securing, analyzing and testing complex systems with a strong focus on identifying and understanding software and infrastructure vulnerabilities.

He currently serves in the advanced research organization of a leading cybersecurity company where he conducts advanced cybersecurity and vulnerability research alongside a team of highly skilled researchers and engineers. His work focuses on discovering and analyzing security vulnerabilities, reverse engineering software and malware, evaluating emerging threats and developing innovative techniques to strengthen the security and resilience of modern computing environments.

Outside of his professional responsibilities, Steve is passionate about sharing knowledge with the global technology community. In his free time, he collaborates with fellow researchers, industry experts and technology professionals to write practical, in-depth technical books covering a broad range of IT disciplines, including software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies.

His publications are designed to make complex technical concepts accessible through clear explanations, real-world examples, and hands-on guidance. Drawing on more than two decades of industry experience, Steve is committed to helping IT professionals, students, educators and technology enthusiasts develop practical skills and stay current with the rapidly evolving technology landscape.

Contents

Table of Contents

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

Introduction: The State of Modern C++ in 2024

Chapter 1: 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 2: 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 3: Core Language Enhancements II: Control Flow and Expressions

  1. Constexpr Control Flow: if consteval and switch 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 4: 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 5: 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 6: 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 7: 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 8: 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 9: 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 10: 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 11: 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 12: 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

Templates and Concepts

Constants and Compile-Time

Appendix E: Common C++23 Interview Questions

Design and Architecture

Performance

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

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