C++17 In Detail: Learn the Exciting Features of The New C++ Standard!

C++17 In Detail: Learn the Exciting Features of The New C++ Standard!

C++17 In Detail: Learn the Exciting Features of The New C++ Standard!
Автор: Filipek Bartlomiej
Дата выхода: 2019
Издательство: Lean Publishing
Количество страниц: 318
Размер файла: 1.0 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Table of Contents....4

About the Author....9

Technical Reviewer....10

Additional Reviewers & Supporters....11

Revision History....13

Preface....14

About the Book....15

Who This Book is For....15

Overall Structure of the Book....16

Reader Feedback....17

Example Code....17

Part 1 - The Language Features....20

Quick Start....21

Fixes and Deprecation....24

Removed Things....25

Fixes....29

Compiler support....32

Language Clarification....33

Stricter Expression Evaluation Order....34

Guaranteed Copy Elision....38

Dynamic Memory Allocation for Over-Aligned Data....43

Exception Specifications as Part of the Type System....44

Compiler Support....44

General Language Features....45

Structured Binding Declarations....46

Init Statement for if and switch....53

Inline Variables....55

constexpr Lambda Expressions....57

Nested Namespaces....59

Compiler support....60

Templates....61

Template Argument Deduction for Class Templates....62

Fold Expressions....66

if constexpr....69

Declaring Non-Type Template Parameters With auto....77

Other Changes....78

Compiler Support....80

Standard Attributes....81

Why Do We Need Attributes?....82

Before C++11....82

Attributes in C++11 and C++14....83

C++17 additions....85

Section Summary....90

Compiler support....91

Part 2 - The Standard Library Changes....92

std::optional....93

Introduction....94

std::optional Creation....96

Returning std::optional....100

Accessing The Stored Value....102

std::optional Operations....103

Examples of std::optional....105

Performance & Memory Consideration....107

Migration from boost::optional....109

Special case: optional and optional....109

Summary....110

Compiler Support....110

std::variant....111

The Basics....112

std::variant Creation....115

Changing the Values....118

Accessing the Stored Value....120

Visitors for std::variant....121

Other std::variant Operations....126

Exception Safety Guarantees....126

Performance & Memory Considerations....127

Migration From boost::variant....128

Examples of std::variant....129

Wrap Up....136

Compiler Support....137

std::any....138

The Basics....139

std::any Creation....141

Changing the Value....143

Accessing The Stored Value....144

Performance & Memory Considerations....145

Migration from boost::any....146

Examples of std::any....146

Wrap Up....149

Compiler Support....149

std::string_view....150

The Basics....151

The std::basic_string_view Type....152

std::string_view Creation....153

Other Operations....154

Risks Using string_view....156

Initializing string Members from string_view....160

Handling Non-Null Terminated Strings....163

Performance & Memory Considerations....166

Migration from boost::string_ref and boost::string_view....167

Examples....168

Wrap Up....171

String Conversions....172

Elementary String Conversions....173

Converting From Characters to Numbers: from_chars....174

Converting Numbers into Characters: to_chars....177

The Benchmark....180

Summary....184

Compiler support....185

Searchers & String Matching....186

Overview of String Matching Algorithms....187

New Algorithms Available in C++17....188

Examples....189

Summary....195

Compiler support....195

Filesystem....196

Filesystem Overview....197

Demo....197

The Path Object....200

The Directory Entry & Directory Iteration....208

Supporting Functions....209

Error Handling & File Races....215

Examples....216

Chapter Summary....221

Compiler Support....223

Parallel STL Algorithms....224

Introduction....225

Overview....226

Execution Policies....227

Algorithm Update....232

New Algorithms....233

Performance of Parallel Algorithms....237

Examples....238

Chapter Summary....249

Compiler Support....251

Other Changes In The Library....252

std::byte....253

Improvements for Maps and Sets....254

Return Type of Emplace Methods....260

Sampling Algorithms....261

New Mathematical Functions....262

Shared Pointers and Arrays....264

Non-member size(), data() and empty()....265

constexpr Additions to the Standard Library....266

std::scoped_lock....268

std::iterator Is Deprecated....269

Polymorphic Allocator, pmr....271

Compiler support....273

Part 3 - More Examples and Use Cases....274

Refactoring with std::optional and std::variant....275

The Use Case....276

The Tuple Version....277

A Separate Structure....278

With std::optional....279

With std::variant....280

Wrap up....282

Enforcing Code Contracts With [[nodiscard]]....283

Introduction....284

Where Can It Be Used?....284

How to Ignore [[nodiscard]]....287

Before C++17....288

Summary....288

Replacing enable_if with if constexpr - Factory with Variable Arguments....289

The Problem....290

Before C++17....292

With if constexpr....293

Summary....294

How to Parallelise CSV Reader....295

Introduction and Requirements....296

The Serial Version....297

Using Parallel Algorithms....303

Wrap up & Discussion....309

Appendix A - Compiler Support....312

GCC....312

Clang....312

VisualStudio - MSVC....312

Compiler Support of C++17 Features....313

Appendix B - Resources and References....316

After the long awaited C++11, the C++ Committee has made changes to the standardisation process and we can now expect a new language standard every three years. In 2014 the ISO Committee delivered C++14. Now it’s time for C++17, which was published at the end of 2017. As I am writing these words, in the middle of 2018, we’re in the process of preparing C++20.

As you can see, the language and the Standard Library evolves quite fast! Since 2011 you’ve got a set of new library modules and language features every three years. Thus staying up to date with the whole state of the language has become quite a challenging task, and this is why this book will help you.

The chapters of this book describe all the significant changes in C++17 and will give you the essential knowledge to stay at the edge of the latest features. What’s more, each section contains lots of practical examples and also compiler-specific notes to give you a more comfortable start.

It’s a pleasure for me to write about new and exciting things in the language and I hope you’ll have fun discovering C++17 as well!


Похожее:

Список отзывов:

Нет отзывов к книге.