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
C++17 STL Cookbook

You're reading from   C++17 STL Cookbook Discover the latest enhancements to functional programming and lambda expressions

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781787120495
Length 532 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Jacek Galowicz Jacek Galowicz
Author Profile Icon Jacek Galowicz
Jacek Galowicz
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. The New C++17 Features FREE CHAPTER 2. STL Containers 3. Iterators 4. Lambda Expressions 5. STL Algorithm Basics 6. Advanced Use of STL Algorithms 7. Strings, Stream Classes, and Regular Expressions 8. Utility Classes 9. Parallelism and Concurrency 10. Filesystem

What you need for this book

All recipes in this book are kept as simple and self-contained as possible. They are easy to compile and run, but depending on the reader’s choice of operating system and compiler, there are differences. Let’s have a look how to compile and run all the recipes, and what else to pay attention to.

Compiling and running the recipes

All the code in this book has been developed and tested on Linux and MacOS, using the GNU C++ compiler, g++, and the LLVM C++ compiler, clang++.

Building an example in the shell can be done with the following command using g++:

$ g++ -std=c++1z -o recipe_app recipe_code.cpp

Using clang++, the command is similar:

$ clang++ -std=c++1z –o recipe_app recipe_code.cpp

Both the command-line examples assume that the file recipe_code.cpp is the text file containing your C++ code. After compiling the program, the executable binary will have the filename recipe_app and can be executed as follows:

$ ./recipe_app

In a lot of examples, we read the content of entire files via standard input. In such cases, we use the standard UNIX pipes and the UNIX cat command to direct the file content into our app, as follows:

$ cat file.txt | ./recipe_app

This works on Linux and MacOS. In the Microsoft Windows shell, it works as follows:

> recipe_app.exe < file.txt

If you do not happen to run your programs from the command-line shell, but from the Microsoft Visual Studio IDE, then you need to open the dialogue, "Configuration properties > Debugging", and add the "< file.txt" part to the command line of the app that Visual Studio uses for launching.

Requirements for early adopters

If you happen to read this book in the earliest days of C++17 and use bleeding- edge compilers to compile the code, you might experience that some recipes do not compile yet. This depends on how much of the C++17 STL has been implemented already in your STL distribution.
While writing this book, it was necessary to add the path prefix experimental/ to the headers <execution_policy> and <filesystem>. There might also be additional includes such as algorithm, numeric, and so on, in the experimental/ folder of your STL distribution, depending on how new and stable it is.

The same applies for the namespace of brand new features. The parts of the library that were included from the experimental part of the STL are usually exported not within the std namespace but the std::experimental namespace.

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