Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Modern C++ Programming Cookbook

You're reading from   Modern C++ Programming Cookbook Master Modern C++ with comprehensive solutions for C++23 and all previous standards

Arrow left icon
Product type Paperback
Published in Feb 2024
Publisher Packt
ISBN-13 9781835080542
Length 816 pages
Edition 3rd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Marius Bancila Marius Bancila
Author Profile Icon Marius Bancila
Marius Bancila
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Learning Modern Core Language Features 2. Working with Numbers and Strings FREE CHAPTER 3. Exploring Functions 4. Preprocessing and Compilation 5. Standard Library Containers, Algorithms, and Iterators 6. General-Purpose Utilities 7. Working with Files and Streams 8. Leveraging Threading and Concurrency 9. Robustness and Performance 10. Implementing Patterns and Idioms 11. Exploring Testing Frameworks 12. C++ 20 Core Features 13. Other Books You May Enjoy
14. Index

What’s new in this edition

This section provides a list of new or updated recipes along with a short description of the change.

Chapter 1, Learning Modern Core Language Features:

  • Using scope enumeration: updated with C++23 std::to_underlying and std::is_scoped_enum
  • Using range-based for loops to iterate on a range: updated with the C++23 init statement
  • Using the subscript operator to access elements in a collection: (new) C++23 multidimensional subscript operator

Chapter 2, Working with Numbers and Strings:

  • Understanding the various numeric types: (new) explains the C++ numerical types
  • Understanding the various character and string types: (new) explains the C++ character types
  • Printing Unicode characters to the output console: (new) discusses working with UNICODE and printing to the console
  • Creating a library of string helpers: updated with C++20 starts_with(), ends_with(), and contains()
  • Formatting and printing text with std::format and std::print: updated with C++23 std::print() and std::println()
  • Using std::format with user-defined types: updated with C++23 std::formattable and better examples

Chapter 3, Exploring Functions:

  • Using lambdas with standard algorithms: updated with C++23 attributes on function call operators
  • Writing a recursive lambda: updated with C++14 recursive generic lambdas
  • Writing function templates: (new) a walkthrough of writing function templates

Chapter 4, Preprocessing and Compilation:

  • Conditionally compiling your source code: updated with C++23 #warning, #elifdef, and #elifndef
  • Performing compile time assertion checks with static_assert: updated with C++26 user-generated messages
  • Providing metadata to the compiler with attributes: updated with C++23 attributes on lambda, [[assume]], and duplicate attributes

Chapter 5, Standard Library Containers, Algorithms, and Iterators:

  • Using vector as default container: updated with C++23 range-aware member functions
  • Selecting the right standard containers (new) a comparison of standard containers

Chapter 6, General-Purpose Utilities:

  • Working with calendars: updated with C++20-compliant examples
  • Converting times between timezones: updated with C++20-compliant examples
  • Chaining together computations which may or may not produce a value: (new) discusses the C++23 std::optional monadic operations
  • Using std::expected for returning a value or an error: (new) discusses the C++23 std::expected type
  • Using std::mdspan for multidimensional views of sequences of objects: (new) explores the C++23 std::mdspan type
  • Providing logging details with source_location: (new) explores the C++20 std::source_location type
  • Using the stacktrace library to print the call stack: (new) teaches the C++23 stacktrace library

Chapter 7, Working with Files and Streams:

  • Using streams on fixed-size external buffers: (new) explores the C++23 span buffers

Chapter 8, Leveraging Threading and Concurrency:

  • Using thread synchronization mechanisms: updated with C++20-compliant samples
  • Synchronizing output streams: (new) discusses the C++20 sync streams

Chapter 9, Robustness and Performance:

  • Creating compile-time constant expressions: updated with C++23 static constexpr variables
  • Optimizing code in constant-evaluated contexts: (new) explains the C++23 if consteval
  • Using virtual function calls in constant expressions: (new) discusses the C++20 constexpr virtual functions

Chapter 10, Implementing Patterns and Idioms:

  • Adding functionality to classes with mixins: (new) explains the mixins pattern
  • Handling unrelated types generically with type erasure: (new) discusses the type erasure idiom

Chapter 11, Exploring Testing Frameworks:

  • Getting started with Catch2: updated installation instructions for Catch2 version 3.4.0
  • Asserting with Catch2: updated examples for Catch2 version 3.4.0

Chapter 12, C++20 Core Features:

  • Exploring abbreviated function templates: (new) examines C++20 abbreviated function templates
  • Exploring the standard range adaptors: (new) discusses the C++20 and C++23 range adaptors
  • Converting a range to a container: (new) explains how to convert a range to a standard container using C++23 std::ranges::to()
  • Using constrained algorithms: (new) explores the general-purpose algorithms that work directly with ranges
  • Creating a coroutine task for asynchronous computation: updated with standard compliant examples (and alternatives with the libcoro library)
  • Creating a coroutine generator type for sequences of values: updated with standard compliant examples (and alternatives with the libcoro library)
  • Recursively generating values with the std::generator type: (new) explains the C++23 std::generator
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image