C++17 - The Complete Guide (C++17 - The Complete Guide)
$19.90
Minimum price
$39.90
Suggested price

C++17 - The Complete Guide

About the Book

C++17 is the next evolution in modern C++ programming, which is now supported by the latest version of gcc, clang, and Visual C++. Although it is not as big a step as C++11, it contains a large number of small and valuable language and library features, which will change the way we program in C++. As usual, not everything is self-explanatory, combining new features gives even more power, and there are hidden traps.

This book presents all the new language and library features of C++17. It covers the motivation and context of each new feature with examples and background information. The focus is on how these features impact day-to-day programming, what it means to combine them, and how to benefit from this in practice.

Testimonials:

"It's very clearly written and the examples are really helpful!" Graham Markall

"I am thoroughly enjoying the book; I had skimmed the list of changes in C++17 several times before but until I started reading your book I had no idea how substantial the changes really were. It makes me wonder what I overlooked with previous updates!" Jason Birch

"I thought I knew a bit about C++. I downloaded this book and learned something new in the *preface*. Highly recommended so far!" Tristan Brindle

Buy early, pay less, free updates

Note that this book was published step-by-step. It started with 270 pages first published in December 2018. Since then the contents grows with new chapters, examples, and caveats about the features of C++17 and I integrate all feedback I get for the pages already published.

The current version now covers all new features of C++17, both core language and library features.

See www.cppstd17.com for a detailed list of covered topics.

As written, once you bought it you will get all updates for free.

PDF versus Other Formats

I write the book in LaTeX and generate PDF from it (the way I wrote my other books). The other formats (epub, mobi, and online reading) come from the leanpub markdown interface, for which I generate the necessary input from LaTeX by script.

Thus, the PDF layout has a better quality than the other formats. For example, the syntax highlighting rules for the formats other than PDF have to get fixed as soon as possible and the index is missing yet. Leanpub and me are working on corresponding improvements.

I hope you enjoy and benefit.

Nico

#cpp17tcg

About the Author

Nicolai M. Josuttis
Nicolai M. Josuttis

Nicolai Josuttis (http://www.josuttis.com) is well known in the programming community because he not only speaks and writes with authority, being the (co-)author of the world-wide best sellers

but is also an innovative presenter, having talked at various conferences and events.

He is an independent trainer and speaker being active in C++ standardization for more than 20 years.

Bundles that include this book

$59.70
Bought separately
$49.50
Bundle Price
$109.60
Bought separately
$59.00
Minimum price
$89.00
Suggested price

Table of Contents

  •  
    • Preface
      • Versions of This Book
      • Acknowledgments
    • About This Book
      • What You Should Know Before Reading This Book
      • Overall Structure of the Book
      • How to Read This Book
      • Error Terminology
      • The C++17 Standard
      • Example Code and Additional Information
      • Feedback
  • I Basic Language Features
    • 1. Structured Bindings
      • 1.1 Structured Bindings in Detail
      • 1.2 Where Structured Bindings Can Be Used
        • 1.2.1 Structures and Classes
        • 1.2.2 Raw Arrays
        • 1.2.3 std::pair, std::tuple, and std::array
      • 1.3 Providing a Tuple-Like API for Structured Bindings
      • 1.4 Afternotes
    • 2. if and switch with Initialization
      • 2.1 if with Initialization
      • 2.2 switch with Initialization
      • 2.3 Afternotes
    • 3. Inline Variables
      • 3.1 Motivation for Inline Variables
      • 3.2 Using Inline Variables
      • 3.3 constexpr Now Implies inline For Static Members
      • 3.4 Inline Variables and thread_local
      • 3.5 Afternotes
    • 4. Aggregate Extensions
      • 4.1 Motivation for Extended Aggregate Initialization
      • 4.2 Using Extended Aggregate Initialization
      • 4.3 Definition of Aggregates
      • 4.4 Backward Incompatibilities
      • 4.5 Afternotes
    • 5. Mandatory Copy Elision or Passing Unmaterialized Objects
      • 5.1 Motivation for Mandatory Copy Elision for Temporaries
      • 5.2 Benefit of Mandatory Copy Elision for Temporaries
      • 5.3 Clarified Value Categories
        • 5.3.1 Value Categories
        • 5.3.2 Value Categories Since C++17
      • 5.4 Unmaterialized Return Value Passing
      • 5.5 Afternotes
    • 6. Lambda Extensions
      • 6.1 constexpr Lambdas
        • 6.1.1 Using constexpr Lambdas
      • 6.2 Passing Copies of this to Lambdas
      • 6.3 Capturing by const Reference
      • 6.4 Afternotes
    • 7. New Attributes and Attribute Features
      • 7.1 Attribute [[nodiscard]]
      • 7.2 Attribute [[maybe_unused]]
      • 7.3 Attribute [[fallthrough]]
      • 7.4 General Attribute Extensions
      • 7.5 Afternotes
    • 8. Other Language Features
      • 8.1 Nested Namespaces
      • 8.2 Defined Expression Evaluation Order
      • 8.3 Relaxed Enum Initialization from Integral Values
      • 8.4 Fixed Direct List Initialization with auto
      • 8.5 Hexadecimal Floating-Point Literals
      • 8.6 UTF-8 Character Literals
      • 8.7 Exception Specifications as Part of the Type
      • 8.8 Single-Argument static_assert
      • 8.9 Preprocessor Condition __has_include
      • 8.10 Afternotes
  • II Template Features
    • 9. Class Template Argument Deduction
      • 9.1 Use of Class Template Argument Deduction
        • 9.1.1 Copying by Default
        • 9.1.2 Deducing the Type of Lambdas
        • 9.1.3 No Partial Class Template Argument Deduction
        • 9.1.4 Class Template Argument Deduction Instead of Convenience Functions
      • 9.2 Deduction Guides
        • 9.2.1 Using Deduction Guides to Force Decay
        • 9.2.2 Non-Template Deduction Guides
        • 9.2.3 Deduction Guides versus Constructors
        • 9.2.4 Explicit Deduction Guides
        • 9.2.5 Deduction Guides for Aggregates
        • 9.2.6 Standard Deduction Guides
      • 9.3 Afternotes
    • 10. Compile-Time if
      • 10.1 Motivation for Compile-Time if
      • 10.2 Using Compile-Time if
        • 10.2.1 Caveats for Compile-Time if
        • 10.2.2 Other Compile-Time if Examples
      • 10.3 Compile-Time if with Initialization
      • 10.4 Using Compile-Time if Outside Templates
      • 10.5 Afternotes
    • 11. Fold Expressions
      • 11.1 Motivation for Fold Expressions
      • 11.2 Using Fold Expressions
        • 11.2.1 Dealing with Empty Parameter Packs
        • 11.2.2 Supported Operators
        • 11.2.3 Using Fold Expressions for Types
      • 11.3 Afternotes
    • 12. Dealing with String Literals as Template Parameters
      • 12.1 Using Strings in Templates
      • 12.2 Afternotes
    • 13. Placeholder Types like auto as Template Parameters
      • 13.1 Using auto for Template Parameters
        • 13.1.1 Parameterizing Templates for Characters and Strings
        • 13.1.2 Defining Metaprogramming Constants
      • 13.2 Using auto as Variable Template Parameter
      • 13.3 Using decltype(auto) as Template Parameter
      • 13.4 Afternotes
    • 14. Extended Using Declarations
      • 14.1 Using Variadic Using Declarations
      • 14.2 Variadic Using Declarations for Inheriting Constructors
      • 14.3 Afternotes
  • III New Library Components
    • 15. std::optional<>
      • 15.1 Using std::optional<>
        • 15.1.1 Optional Return Values
        • 15.1.2 Optional Arguments and Data Members
      • 15.2 std::optional<> Types and Operations
        • 15.2.1 std::optional<> Types
        • 15.2.2 std::optional<> Operations
      • 15.3 Special Cases
        • 15.3.1 Optional of Boolean or Raw Pointer Values
        • 15.3.2 Optional of Optional
      • 15.4 Afternotes
    • 16. std::variant<>
      • 16.1 Motivation for std::variant<>
      • 16.2 Using std::variant<>
      • 16.3 std::variant<> Types and Operations
        • 16.3.1 std::variant<> Types
        • 16.3.2 std::variant<> Operations
        • 16.3.3 Visitors
        • 16.3.4 Valueless by Exception
      • 16.4 Polymorphism and Heterogeneous Collections with std::variant
        • 16.4.1 Geometric Objects with std::variant
        • 16.4.2 Other Heterogeneous Collections with std::variant
        • 16.4.3 Comparing variant Polymorphism
      • 16.5 Special Cases with std::variant<>
        • 16.5.1 Having Both bool and std::string Alternatives
      • 16.6 Afternotes
    • 17. std::any
      • 17.1 Using std::any
      • 17.2 std::any Types and Operations
        • 17.2.1 Any Types
        • 17.2.2 Any Operations
      • 17.3 Afternotes
    • 18. std::byte
      • 18.1 Using std::byte
      • 18.2 std::byte Types and Operations
        • 18.2.1 std::byte Types
        • 18.2.2 std::byte Operations
      • 18.3 Afternotes
    • 19. String Views
      • 19.1 Differences Compared to std::string
      • 19.2 Using String Views
      • 19.3 Using String Views as Parameters
        • 19.3.1 String View Considered Harmful
      • 19.4 String View Types and Operations
        • 19.4.1 Concrete String View Types
        • 19.4.2 String View Operations
        • 19.4.3 String View Support by Other Types
      • 19.5 Using String Views in APIs
        • 19.5.1 Using String Views instead of Strings
      • 19.6 Afternotes
    • 20. The Filesystem Library
      • 20.1 Basic Examples
        • 20.1.1 Print Attributes of a Passed Filesystem Path
        • 20.1.2 Switch Over Filesystem Types
        • 20.1.3 Create Different Types of Files {#createfiles.cpp}
        • 20.1.4 Dealing with Filesystems Using Parallel Algorithms
      • 20.2 Principles and Terminology
        • 20.2.1 General Portability Disclaimer
        • 20.2.2 Namespace
        • 20.2.3 Paths
        • 20.2.4 Normalization
        • 20.2.5 Member Function versus Free-Standing Functions
        • 20.2.6 Error Handling
        • 20.2.7 File Types
      • 20.3 Path Operations
        • 20.3.1 Path Creation
        • 20.3.2 Path Inspection
        • 20.3.3 Path I/O and Conversions
        • 20.3.4 Conversions Between Native and Generic Format
        • 20.3.5 Path Modifications
        • 20.3.6 Path Comparisons
        • 20.3.7 Other Path Operations
      • 20.4 Filesystem Operations
        • 20.4.1 File Attributes
        • 20.4.2 File Status
        • 20.4.3 Permissions
        • 20.4.4 Filesystem Modifications
        • 20.4.5 Symbolic Links and Filesystem-Dependent Path Conversions
        • 20.4.6 Other Filesystem Operations
      • 20.5 Iterating Over Directories
        • 20.5.1 Directory Entries
      • 20.6 Afternotes
  • IV Library Extensions and Modifications
    • 21. Extensions of Type Traits
      • 21.1 Type Traits Suffix _v
      • 21.2 New Type Traits
      • 21.3 Afternotes
    • 22. Parallel STL Algorithms
      • 22.1 Using Parallel Algorithms
        • 22.1.1 Using a Parallel for_each()
        • 22.1.2 Using a Parallel sort()
      • 22.2 Execution Policies
      • 22.3 Exception Handling
      • 22.4 Benefit of Not Using Parallel Algorithms
      • 22.5 Overview of Parallel Algorithms
      • 22.6 Motivation for New Algorithms for Parallel Processing
        • 22.6.1 reduce()
      • 22.7 Afternotes
    • 23. New STL Algorithms in Detail
      • 23.1 std::for_each_n()
      • 23.2 New Numeric STL Algorithms
        • 23.2.1 std::reduce()
        • 23.2.2 std::transform_reduce()
        • 23.2.3 std::inclusive_scan() and std::exclusive_scan()
        • 23.2.4 std::transform_inclusive_scan() and std::transform_exclusive_scan()
      • 23.3 Afternotes
    • 24. Substring and Subsequence Searchers
      • 24.1 Using Substring Searchers
        • 24.1.1 Using Searchers with search()
        • 24.1.2 Using Searchers Directly
      • 24.2 Using General Subsequence Searchers
      • 24.3 Using Searcher Predicates
      • 24.4 Afternotes
    • 25. Other Utility Functions and Algorithms
      • 25.1 size(), empty(), and data()
        • 25.1.1 Generic size() Function
        • 25.1.2 Generic empty() Function
        • 25.1.3 Generic data() Function
      • 25.2 as_const()
        • 25.2.1 Capturing by Const Reference
      • 25.3 clamp()
      • 25.4 sample()
      • 25.5 Afternotes
    • 26. Container and String Extensions
      • 26.1 Node Handles
        • 26.1.1 Modifying a Key
        • 26.1.2 Moving Nodes Between Containers
        • 26.1.3 Merging Containers
      • 26.2 Emplace Improvements
        • 26.2.1 Return Type of Emplace Functions
        • 26.2.2 try_emplace() and insert_or_assign() for Maps
      • 26.3 Container Support for Incomplete Types
      • 26.4 String Improvements
      • 26.5 Afternotes
    • 27. Multi-Threading and Concurrency
      • 27.1 Supplementary Mutexes and Locks
        • 27.1.1 std::scoped_lock
        • 27.1.2 std::shared_mutex
      • 27.2 is_always_lock_free for Atomics
      • 27.3 Cache Line Sizes
      • 27.4 Afternotes
    • 28. Other Small Library Features and Modifications
      • 28.1 std::uncaught_exceptions()
      • 28.2 Shared Pointer Improvements
        • 28.2.1 Special handling for Shared Pointers to Raw C Arrays
        • 28.2.2 reinterpret_pointer_cast for Shared Pointers
        • 28.2.3 weak_type for Shared Pointers
        • 28.2.4 weak_from_this for Shared Pointers
      • 28.3 Numeric Extensions
        • 28.3.1 Greatest Common Divisor and Least Common Multiple
        • 28.3.2 Three-Argument Overloads of std::hypot()
        • 28.3.3 Mathematical Special Functions
      • 28.4 chrono Extensions
      • 28.5 constexpr Extensions and Fixes
      • 28.6 noexcept Extensions and Fixes
      • 28.7 Afternotes
  • V Expert Utilities
    • 29. Polymorphic Memory Resources (PMR)
      • 29.1 Using Standard Memory Resources
        • 29.1.1 Motivating Example
        • 29.1.2 Standard Memory Resources
        • 29.1.3 Standard Memory Resources in Detail
      • 29.2 Defining Custom Memory Resources
        • 29.2.1 Equality of Memory Resources
      • 29.3 Providing Memory Resource Support for Custom Types
        • 29.3.1 Definition of a PMR Type
        • 29.3.2 Using a PMR Type
        • 29.3.3 Dealing with the Different Types
      • 29.4 Afternotes
    • 30. new and delete with Over-Aligned Data
      • 30.1 Using new with Alignments
        • 30.1.1 Distinct Dynamic/Heap Memory Arenas
        • 30.1.2 Passing the Alignment with the new Expression
      • 30.2 Implementing operator new() for Aligned Memory
        • 30.2.1 Implementing Aligned Allocation Before C++17
        • 30.2.2 Implementing Type-Specific operator new()
      • 30.3 Implementing Global operator new()
        • 30.3.1 Backward Incompatibilities
      • 30.4 Tracking All ::new Calls
      • 30.5 Afternotes
    • 31. std::to_chars() and std::from_chars()
      • 31.1 Motivation for Low-Level Conversions between Character Sequences and Numeric Values
      • 31.2 Example Usage
        • 31.2.1 from_chars()
        • 31.2.2 to_chars()
      • 31.3 Floating-Point Round-Trip Support
      • 31.4 Afternotes
    • 32. std::launder()
      • 32.1 Motivation for std::launder()
      • 32.2 How launder() Solves the Problem
      • 32.3 Why/When launder() Does Not Work
      • 32.4 Afternotes
    • 33. Improvements for Implementing Generic Code
      • 33.1 std::invoke<>()
      • 33.2 std::bool_constant<>
      • 33.3 std::void_t<>
      • 33.4 Afternotes
  • VI Final General Hints
    • 34. Common C++17 Settings
      • 34.1 Value of __cplusplus
      • 34.2 Compatibility to C11
      • 34.3 Dealing with Signal Handlers
      • 34.4 Forward Progress Guarantees
      • 34.5 Afternotes
    • 35. Deprecated and Removed Features
      • 35.1 Deprecated and Removed Core Language Features
        • 35.1.1 Throw Specifications
        • 35.1.2 Keyword register
        • 35.1.3 Disable ++ for bool
        • 35.1.4 Trigraphs
        • 35.1.5 Definition/Redeclaration of static constexpr Members
      • 35.2 Deprecated and Removed Library Features
        • 35.2.1 auto_ptr
        • 35.2.2 Algorithm random_shuffle()
        • 35.2.3 unary_function and binary_function
        • 35.2.4 ptr_fun(), mem_fun(), and Binders
        • 35.2.5 Allocator Support for std::function<>
        • 35.2.6 Deprecated IOStream Aliases
        • 35.2.7 Deprecated Library Features
      • 35.3 Afternotes
    • Glossary
      • B
        • bitmask type
      • F
        • full specialization
      • I
        • incomplete type
      • P
        • partial specialization
      • S
        • small/short string optimization (SSO)
      • V
        • variable template
        • variadic template
  • Notes

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.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, 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