Expert C++ Programming

Developing expert level application development skills with C++
Preview in Mapt

Expert C++ Programming

Jeganathan Swaminathan, Maya Posch, Jacek Galowicz
New Release!

Developing expert level application development skills with C++
Mapt Subscription
FREE
$29.99/m after trial
eBook
$10.00
RRP $79.99
Save 87%
Print + eBook
$99.99
RRP $99.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$10.00
$99.99
$29.99 p/m after trial
RRP $79.99
RRP $99.99
Subscription
eBook
Print + eBook
Start 14 Day Trial

Frequently bought together


Expert C++ Programming Book Cover
Expert C++ Programming
$ 79.99
$ 10.00
C++ Data Structures and Algorithms Book Cover
C++ Data Structures and Algorithms
$ 35.99
$ 10.00
Buy 2 for $20.00
Save $95.98
Add to Cart

Book Details

ISBN 139781788831390
Paperback1030 pages

Book Description

C++ has ​ ​come ​ ​a ​ ​long ​ ​way ​ ​and ​ ​has ​ ​now ​ ​been ​ ​adopted ​ ​in ​ ​several ​ ​contexts. Its ​ ​key ​strengths ​ ​are ​ ​its ​ ​software ​ ​infrastructure ​ ​and ​ ​resource-constrained applications. ​ ​The ​C++ ​ ​17 ​ ​release ​ ​will ​ ​change ​ ​the ​ ​way ​ ​developers ​ ​write code, ​ ​and ​ ​this ​ ​course ​ ​will ​ ​help ​you ​ ​master ​ ​your ​ ​developing ​ ​skills ​ ​with ​ ​C++. With ​ ​real-world, ​ ​practical ​ ​examples ​ ​explaining ​ ​each ​ ​concept, ​ ​the ​ ​course is divided into three modules where ​ ​will begin ​ ​by ​ ​introducing ​ ​you ​ ​to ​ ​the ​ ​latest ​ ​features ​ ​in ​ ​C++ ​ ​17. ​ ​It ​ ​encourages clean ​code ​ ​practices ​ ​in ​ ​C++ ​ ​in ​ ​general ​ ​and ​ ​demonstrates ​ ​the ​ ​GUI app-development ​ ​options ​ ​in ​ ​C++. ​ ​You’ll ​ ​get ​ ​tips ​ ​on ​ ​avoiding ​ ​memory ​ ​leaks using ​ ​smart-pointers.

In the next module, ​ ​you’ll ​ ​see ​ ​how ​ ​multi-threaded ​programming can ​ ​help ​ ​you ​ ​achieve ​ ​concurrency ​ ​in ​ ​your ​ ​applications. We start with a brief introduction to the fundamentals of multithreading and concurrency concepts. We then take an in-depth look at how these concepts work at the hardware-level as well as how both operating systems and frameworks use these low-level functions.

You will learn about the native multithreading and concurrency support available in C++ since the 2011 revision, synchronization and communication between threads, debugging concurrent C++ applications, and the best programming practices in C++.

Moving ​ ​on, ​ ​you’ll ​ ​get ​ ​an ​ ​in-depth ​ ​understanding ​ ​of ​ ​the ​ ​C++ ​ ​Standard Template ​ ​Library. ​Where we show implementation-specific, problem-solution approach that will help you quickly overcome hurdles. You will learn the core STL concepts, such as containers, algorithms, utility classes, lambda expressions, iterators, and more while working on practical real-world recipes. These recipes will help you get the most from the STL and show you how to program in a better way.

Jeganathan Swaminathan : Mastering C++ Programming
Maya Posch : Mastering C++ Multithreading
Jacek Galowicz : C++17 STL Cookbook

Table of Contents

Chapter 1: Introduction to C++17 Standard Template Library
The Standard Template Library architecture
Sequence containers
Associative containers
Container adapters
Summary
Chapter 2: Template Programming
Generic programming
Summary
Chapter 3: Smart Pointers
Memory management
Issues with raw pointers
Smart pointers
Summary
Chapter 4: Developing GUI Applications in C++
Qt 
Qt Core
Qt Widgets
Layouts
Signals and slots
Using stacked layout in Qt applications
Summary
Chapter 5: Test-Driven Development
TDD
Common myths and questions around TDD
Unit testing frameworks for C++
Google test framework
TDD in action
Summary
Chapter 6: Behavior-Driven Development
Behavior-driven development
TDD versus BDD
C++ BDD frameworks
The Gherkin language
Installing cucumber-cpp in Ubuntu
Feature file
Spoken languages supported by Gherkin
The recommended cucumber-cpp project folder structure
Writing our first Cucumber test case
Dry running your cucumber test cases
BDD - a test-first development approach
Summary
Chapter 7: Code Smells and Clean Code Practices
Code refactoring
Code smell
What is agile?
SOLID design principle
Code smell
Summary
Chapter 8: Revisiting Multithreading
Getting started
The multithreaded application
Other applications
Summary
Chapter 9: Multithreading Implementation on the Processor and OS
Introduction to POSIX pthreads
Creating threads with the pthreads library
Does C++ support threads natively?
Defining processes and threads
The stack
Defining multithreading
Schedulers
Tracing the demo application
Mutual exclusion implementations
Concurrency
Summary
Chapter 10: C++ Multithreading APIs
API overview
POSIX threads
Windows threads
Boost
C++ threads
Putting it together
Summary
Chapter 11: Thread Synchronization and Communication
Safety first
The scheduler
Sharing data
Summary
Chapter 12: Native C++ Threads and Primitives
The STL threading API
The 2011 standard
C++14
Thread class
Mutex
Shared mutex
Condition variable
Future
Atomics
Summary
Chapter 13: Debugging Multithreaded Code
When to start debugging
The humble debugger
Dynamic analysis tools
Summary
Chapter 14: Best Practices
Proper multithreading
Wrongful expectations - deadlocks
Being careless - data races
Mutexes aren't magic
Locks are fancy mutexes
Threads versus the future
Static order of initialization
Summary
Chapter 15: Atomic Operations - Working with the Hardware
Atomic operations
Summary
Chapter 16: Multithreading with Distributed Computing
Distributed computing, in a nutshell
Installing Open MPI
Distributing jobs across nodes
MPI communication
MPI versus threads
Potential issues
Summary
Chapter 17: Multithreading with GPGPU
The GPGPU processing model
Setting up a development environment
A basic OpenCL application
GPU memory management
GPGPU and multithreading
Potential issues
Debugging GPGPU applications
Summary
Chapter 18: The New C++17 Features
Introduction
Using structured bindings to unpack bundled return values
Limiting variable scopes to if and switch statements
Profiting from the new bracket initializer rules
Letting the constructor automatically deduce the resulting template class type
Simplifying compile time decisions with constexpr-if
Enabling header-only libraries with inline variables
Implementing handy helper functions with fold expressions
Chapter 19: STL Containers
Using the erase-remove idiom on std::vector
Deleting items from an unsorted std::vector in O(1) time
Accessing std::vector instances the fast or the safe way
Keeping std::vector instances sorted
Inserting items efficiently and conditionally into std::map
Knowing the new insertion hint semantics of std::map::insert
Efficiently modifying the keys of std::map items
Using std::unordered_map with custom types
Filtering duplicates from user input and printing them in alphabetical order with std::set
Implementing a simple RPN calculator with std::stack
Implementing a word frequency counter with std::map
Implement a writing style helper tool for finding very long sentences in text with std::multimap
Implementing a personal to-do list using std::priority_queue
Chapter 20: Iterators
Introduction
Building your own iterable range
Making your own iterators compatible with STL iterator categories
Using iterator adapters to fill generic data structures
Implementing algorithms in terms of iterators
Iterating the other way around using reverse iterator adapters
Terminating iterations over ranges with iterator sentinels
Automatically checking iterator code with checked iterators
Building your own zip iterator adapter
Chapter 21: Lambda Expressions
Introduction
Defining functions on the run using lambda expressions
Adding polymorphy by wrapping lambdas into std::function
Composing functions by concatenation
Creating complex predicates with logical conjunction
Calling multiple functions with the same input
Implementing transform_if using std::accumulate and lambdas
Generating cartesian product pairs of any input at compile time
Chapter 22: STL Algorithm Basics
Introduction
Copying items from containers to other containers
Sorting containers
Removing specific items from containers
Transforming the contents of containers
Finding items in ordered and unordered vectors
Limiting the values of a vector to a specific numeric range with std::clamp
Locating patterns in strings with std::search and choosing the optimal implementation
Sampling large vectors
Generating permutations of input sequences
Implementing a dictionary merging tool
Chapter 23: Advanced Use of STL Algorithms
Introduction
Implementing a trie class using STL algorithms
Implementing a search input suggestion generator with tries
Implementing the Fourier transform formula with STL numeric algorithms
Calculating the error sum of two vectors
Implementing an ASCII Mandelbrot renderer
Building our own algorithm - split
Composing useful algorithms from standard algorithms - gather
Removing consecutive whitespace between words
Compressing and decompressing strings
Chapter 24: Strings, Stream Classes, and Regular Expressions
Introduction
Creating, concatenating, and transforming strings
Trimming whitespace from the beginning and end of strings
Getting the comfort of std::string without the cost of constructing std::string objects
Reading values from user input
Counting all words in a file
Formatting your output with I/O stream manipulators
Initializing complex objects from file input
Filling containers from std::istream iterators
Generic printing with std::ostream iterators
Redirecting output to files for specific code sections
Creating custom string classes by inheriting from std::char_traits
Tokenizing input with the regular expression library
Comfortably pretty printing numbers differently per context on the fly
Catching readable exceptions from std::iostream errors
Chapter 25: Utility Classes
Introduction
Converting between different time units using std::ratio
Converting between absolute and relative times with std::chrono
Safely signalizing failure with std::optional
Applying functions on tuples
Quickly composing data structures with std::tuple
Replacing void* with std::any for more type safety
Storing different types with std::variant
Automatically handling resources with std::unique_ptr
Automatically handling shared heap memory with std::shared_ptr
Dealing with weak pointers to shared objects
Simplifying resource handling of legacy APIs with smart pointers
Sharing different member values of the same object
Generating random numbers and choosing the right random number engine
Generating random numbers and letting the STL shape specific distributions
Chapter 26: Parallelism and Concurrency
Introduction
Automatically parallelizing code that uses standard algorithms
Putting a program to sleep for specific amounts of time
Starting and stopping threads
Performing exception safe shared locking with std::unique_lock and std::shared_lock
Avoiding deadlocks with std::scoped_lock
Synchronizing concurrent std::cout use
Safely postponing initialization with std::call_once
Pushing the execution of tasks into the background using std::async
Implementing the producer/consumer idiom with std::condition_variable
Implementing the multiple producers/consumers idiom with std::condition_variable
Parallelizing the ASCII Mandelbrot renderer using std::async
Implementing a tiny automatic parallelization library with std::future
Chapter 27: Filesystem
Introduction
Implementing a path normalizer
Getting canonical file paths from relative paths
Listing all files in directories
Implementing a grep-like text search tool
Implementing an automatic file renamer
Implementing a disk usage counter
Calculating statistics about file types
Implementing a tool that reduces folder size by substituting duplicates with symlinks

What You Will Learn

  • ​Write ​ ​modular ​ ​C++ ​ ​applications ​ ​in ​ ​terms ​ ​of ​ ​the ​ ​existing ​ ​and newly ​ ​introduced ​ ​features
  • ​ ​Identify ​ ​code-smells, ​ ​clean ​ ​up, ​ ​and ​ ​refactor ​ ​legacy ​ ​C++ applications
  • ​ ​Leverage ​ ​the ​ ​possibilities ​ ​provided ​ ​by ​ ​Cucumber ​ ​and ​ ​Google Test/Mock ​ ​to automate ​ ​test ​ ​cases
  • Deep dive into the details of the how various operating systems currently implement multithreading
  • Choose the best multithreading APIs when designing a new application
  • Explore the use of mutexes, spin-locks, and other synchronization concepts and see how to safely pass data between threads
  • Work with strings the STL way instead of handcrafting C-style code
  • Understand standard support classes for concurrency and synchronization, and how to put them to work
  • Use the filesystem library addition available with the C++17 STL

Authors

Table of Contents

Chapter 1: Introduction to C++17 Standard Template Library
The Standard Template Library architecture
Sequence containers
Associative containers
Container adapters
Summary
Chapter 2: Template Programming
Generic programming
Summary
Chapter 3: Smart Pointers
Memory management
Issues with raw pointers
Smart pointers
Summary
Chapter 4: Developing GUI Applications in C++
Qt 
Qt Core
Qt Widgets
Layouts
Signals and slots
Using stacked layout in Qt applications
Summary
Chapter 5: Test-Driven Development
TDD
Common myths and questions around TDD
Unit testing frameworks for C++
Google test framework
TDD in action
Summary
Chapter 6: Behavior-Driven Development
Behavior-driven development
TDD versus BDD
C++ BDD frameworks
The Gherkin language
Installing cucumber-cpp in Ubuntu
Feature file
Spoken languages supported by Gherkin
The recommended cucumber-cpp project folder structure
Writing our first Cucumber test case
Dry running your cucumber test cases
BDD - a test-first development approach
Summary
Chapter 7: Code Smells and Clean Code Practices
Code refactoring
Code smell
What is agile?
SOLID design principle
Code smell
Summary
Chapter 8: Revisiting Multithreading
Getting started
The multithreaded application
Other applications
Summary
Chapter 9: Multithreading Implementation on the Processor and OS
Introduction to POSIX pthreads
Creating threads with the pthreads library
Does C++ support threads natively?
Defining processes and threads
The stack
Defining multithreading
Schedulers
Tracing the demo application
Mutual exclusion implementations
Concurrency
Summary
Chapter 10: C++ Multithreading APIs
API overview
POSIX threads
Windows threads
Boost
C++ threads
Putting it together
Summary
Chapter 11: Thread Synchronization and Communication
Safety first
The scheduler
Sharing data
Summary
Chapter 12: Native C++ Threads and Primitives
The STL threading API
The 2011 standard
C++14
Thread class
Mutex
Shared mutex
Condition variable
Future
Atomics
Summary
Chapter 13: Debugging Multithreaded Code
When to start debugging
The humble debugger
Dynamic analysis tools
Summary
Chapter 14: Best Practices
Proper multithreading
Wrongful expectations - deadlocks
Being careless - data races
Mutexes aren't magic
Locks are fancy mutexes
Threads versus the future
Static order of initialization
Summary
Chapter 15: Atomic Operations - Working with the Hardware
Atomic operations
Summary
Chapter 16: Multithreading with Distributed Computing
Distributed computing, in a nutshell
Installing Open MPI
Distributing jobs across nodes
MPI communication
MPI versus threads
Potential issues
Summary
Chapter 17: Multithreading with GPGPU
The GPGPU processing model
Setting up a development environment
A basic OpenCL application
GPU memory management
GPGPU and multithreading
Potential issues
Debugging GPGPU applications
Summary
Chapter 18: The New C++17 Features
Introduction
Using structured bindings to unpack bundled return values
Limiting variable scopes to if and switch statements
Profiting from the new bracket initializer rules
Letting the constructor automatically deduce the resulting template class type
Simplifying compile time decisions with constexpr-if
Enabling header-only libraries with inline variables
Implementing handy helper functions with fold expressions
Chapter 19: STL Containers
Using the erase-remove idiom on std::vector
Deleting items from an unsorted std::vector in O(1) time
Accessing std::vector instances the fast or the safe way
Keeping std::vector instances sorted
Inserting items efficiently and conditionally into std::map
Knowing the new insertion hint semantics of std::map::insert
Efficiently modifying the keys of std::map items
Using std::unordered_map with custom types
Filtering duplicates from user input and printing them in alphabetical order with std::set
Implementing a simple RPN calculator with std::stack
Implementing a word frequency counter with std::map
Implement a writing style helper tool for finding very long sentences in text with std::multimap
Implementing a personal to-do list using std::priority_queue
Chapter 20: Iterators
Introduction
Building your own iterable range
Making your own iterators compatible with STL iterator categories
Using iterator adapters to fill generic data structures
Implementing algorithms in terms of iterators
Iterating the other way around using reverse iterator adapters
Terminating iterations over ranges with iterator sentinels
Automatically checking iterator code with checked iterators
Building your own zip iterator adapter
Chapter 21: Lambda Expressions
Introduction
Defining functions on the run using lambda expressions
Adding polymorphy by wrapping lambdas into std::function
Composing functions by concatenation
Creating complex predicates with logical conjunction
Calling multiple functions with the same input
Implementing transform_if using std::accumulate and lambdas
Generating cartesian product pairs of any input at compile time
Chapter 22: STL Algorithm Basics
Introduction
Copying items from containers to other containers
Sorting containers
Removing specific items from containers
Transforming the contents of containers
Finding items in ordered and unordered vectors
Limiting the values of a vector to a specific numeric range with std::clamp
Locating patterns in strings with std::search and choosing the optimal implementation
Sampling large vectors
Generating permutations of input sequences
Implementing a dictionary merging tool
Chapter 23: Advanced Use of STL Algorithms
Introduction
Implementing a trie class using STL algorithms
Implementing a search input suggestion generator with tries
Implementing the Fourier transform formula with STL numeric algorithms
Calculating the error sum of two vectors
Implementing an ASCII Mandelbrot renderer
Building our own algorithm - split
Composing useful algorithms from standard algorithms - gather
Removing consecutive whitespace between words
Compressing and decompressing strings
Chapter 24: Strings, Stream Classes, and Regular Expressions
Introduction
Creating, concatenating, and transforming strings
Trimming whitespace from the beginning and end of strings
Getting the comfort of std::string without the cost of constructing std::string objects
Reading values from user input
Counting all words in a file
Formatting your output with I/O stream manipulators
Initializing complex objects from file input
Filling containers from std::istream iterators
Generic printing with std::ostream iterators
Redirecting output to files for specific code sections
Creating custom string classes by inheriting from std::char_traits
Tokenizing input with the regular expression library
Comfortably pretty printing numbers differently per context on the fly
Catching readable exceptions from std::iostream errors
Chapter 25: Utility Classes
Introduction
Converting between different time units using std::ratio
Converting between absolute and relative times with std::chrono
Safely signalizing failure with std::optional
Applying functions on tuples
Quickly composing data structures with std::tuple
Replacing void* with std::any for more type safety
Storing different types with std::variant
Automatically handling resources with std::unique_ptr
Automatically handling shared heap memory with std::shared_ptr
Dealing with weak pointers to shared objects
Simplifying resource handling of legacy APIs with smart pointers
Sharing different member values of the same object
Generating random numbers and choosing the right random number engine
Generating random numbers and letting the STL shape specific distributions
Chapter 26: Parallelism and Concurrency
Introduction
Automatically parallelizing code that uses standard algorithms
Putting a program to sleep for specific amounts of time
Starting and stopping threads
Performing exception safe shared locking with std::unique_lock and std::shared_lock
Avoiding deadlocks with std::scoped_lock
Synchronizing concurrent std::cout use
Safely postponing initialization with std::call_once
Pushing the execution of tasks into the background using std::async
Implementing the producer/consumer idiom with std::condition_variable
Implementing the multiple producers/consumers idiom with std::condition_variable
Parallelizing the ASCII Mandelbrot renderer using std::async
Implementing a tiny automatic parallelization library with std::future
Chapter 27: Filesystem
Introduction
Implementing a path normalizer
Getting canonical file paths from relative paths
Listing all files in directories
Implementing a grep-like text search tool
Implementing an automatic file renamer
Implementing a disk usage counter
Calculating statistics about file types
Implementing a tool that reduces folder size by substituting duplicates with symlinks

Book Details

ISBN 139781788831390
Paperback1030 pages
Read More

Read More Reviews

Recommended for You

C++ Data Structures and Algorithms Book Cover
C++ Data Structures and Algorithms
$ 35.99
$ 10.00
Apache Spark with Python - Big Data with PySpark and Spark [Video] Book Cover
Apache Spark with Python - Big Data with PySpark and Spark [Video]
$ 149.99
$ 10.01
C# 7 and .NET Core 2.0 High Performance Book Cover
C# 7 and .NET Core 2.0 High Performance
$ 35.99
$ 10.00
Tkinter GUI Programming by Example Book Cover
Tkinter GUI Programming by Example
$ 39.99
$ 10.00
Building Blocks of Application Development with C++ [Video] Book Cover
Building Blocks of Application Development with C++ [Video]
$ 124.99
$ 10.00
Learn By Example: C++ Programming - 75 Solved Problems [Video] Book Cover
Learn By Example: C++ Programming - 75 Solved Problems [Video]
$ 50.99
$ 10.00