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-03

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.

Share this book

Bundle

Bundles that include this book

Author

About the Author

Steve T. Publications

Steve T. is a cybersecurity leader, researcher, and engineer with more than 20 years of experience across application security, infrastructure security, vulnerability management, software development, and secure engineering practices. Having built his career alongside the growth of the modern internet, he has worked through multiple generations of technology, evolving security threats, and changing development methodologies.

He is currently part of the advanced research organization at a leading cybersecurity company, where he focuses on emerging threats, security innovation, and the practical application of research. His work involves investigating new attack techniques, evaluating emerging technologies, conducting deep technical analysis, and helping organizations better understand and manage complex security risks.

In addition to his research responsibilities, Steve leads a team of senior engineers and subject matter experts who create technical books, training programs, and educational resources for security professionals. Through this work, he helps engineers, developers, architects, and security practitioners strengthen their skills and build more secure systems.

Steve's technical expertise spans software development, reverse engineering, web application security, penetration testing, security architecture, incident response, vulnerability research, operating system internals, and secure software development. His ability to analyze systems at both the source code and binary levels enables him to bridge the worlds of software engineering, security research, and practical defense.

Over the course of his career, Steve has worked with organizations across a wide range of industries, helping them identify, assess, and remediate security weaknesses in critical applications and infrastructure. He is recognized for combining deep technical expertise with a pragmatic approach to security, focusing on solutions that are effective, sustainable, and aligned with business goals.

Through his work in research, engineering, leadership, and education, Steve continues to contribute to the advancement of cybersecurity and the development of secure, resilient technology systems.

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. Setting Up Your Development Environment
  5. How to Read This Book
  6. Key Takeaways
  7. Exercises
  8. 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. Nested Namespace Definitions
  3. Preprocessor Directives: #elifdef, #elifndef, and #warning
  4. New Preprocessor Features: #elifdef, #elifndef, and #warning
  5. Literal Suffixes for size_t: zu and uz
  6. Extending Temporary Lifetime in Range-Based For Loops
  7. Static Call and Subscript Operators
  8. Simplifying Implicit Move
  9. Labels at the End of Compound Statements
  10. Key Takeaways
  11. Exercises
  12. 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. std::source_location: Better Diagnostics at Compile Time
  5. Template Metaprogramming Patterns with C++23
  6. Performance Implications of Compile-Time Computation
  7. Key Takeaways
  8. Exercises
  9. Challenge Project

Chapter 8: Concurrency and Parallelism Improvements

  1. Concurrency in C++20: A Quick Recap
  2. New Synchronization Features
  3. Memory Model Improvements
  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. Auto Parameter Deduction in Templates
  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
  10. References

Conclusion: The Journey Continues

References

Appendix A: C++23 Feature Reference

Language Features

Library Features

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

Appendix B: Compiler Compatibility Matrix

Minimum Version Requirements

Feature Completeness by Compiler Version

  1. GCC
  2. Clang
  3. MSVC

Compiler Flags

Appendix C: Migration Checklist

Pre-Migration Assessment

Language Feature Migration

Library Feature Migration

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

Testing and Quality

Documentation

Appendix D: Coding Standards for Modern C++23

General Principles

Naming Conventions

Error Handling

Smart Pointers and Memory

Ranges

Templates and Concepts

Formatting

Constants and Compile-Time

Concurrency

Modules

Documentation

Appendix E: Common C++23 Interview Questions

Language Features

Library Features

Design and Architecture

Performance

Appendix F: Glossary

References

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