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

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

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