C++ recipes a problem-solution approach

C++ Recipes: A Problem-Solution Approach is Apress' solution for those C++ programmers looking for a handy code cookbook reference guide. It covers the latest C++ 14 as well as some of the code templates available in the latest Standard Template Library (STL). In this handy reference, you'...

Full description

Bibliographic Details
Main Author: Sutherland, Bruce
Format: eBook
Language:English
Published: [Berkeley, CA], New York, NY Apress, Distributed to the Book trade worldwide by Springer Science+Business Media 2015
Series:The expert's voice in C++
Subjects:
Online Access:
Collection: O'Reilly - Collection details see MPG.ReNa
Table of Contents:
  • Implicit and Default Copy Constructors and Assignment Operators
  • Explicit Copy Constructors and Assignment Operators
  • Disallowing Copy and Assignment
  • Custom Copy Constructors and Assignment Operators
  • Recipe 5-8. Optimizing Code with Move Semantics
  • Problem
  • Solution
  • How It Works
  • Chapter 6: Inheritance
  • Recipe 6-1. Inheriting from a Class
  • Problem
  • Solution
  • How It Works
  • Recipe 6-2. Controlling Access to Member Variables and Methods in Derived Classes
  • Problem
  • Solution
  • How It Works
  • The public Access Specifier
  • The private Access Specifier
  • The protected Access Specifier
  • Recipe 6-3. Hiding Methods in Derived Classes
  • Problem
  • Solution
  • How It Works
  • Recipe 6-4. Using Polymorphic Base Classes
  • Problem
  • Solution
  • How It Works
  • Recipe 6-5. Preventing Method Overrides
  • Problem
  • Solution
  • How It Works
  • Recipe 6-6. Creating Interfaces
  • Problem
  • Solution
  • How It Works
  • Recipe 6-7. Multiple Inheritance
  • Problem
  • Solution
  • How It Works
  • Chapter 7: The STL Containers
  • Recipe 7-1. Storing a Fixed Number of Objects
  • Problem
  • Solution
  • How It Works
  • Recipe 7-2. Storing a Growing Number of Objects
  • Problem
  • Solution
  • How It Works
  • Recipe 7-3. Storing a Set of Elements that Is Constantly Altered
  • Problem
  • Solution
  • How It Works
  • Recipe 7-4. Storing Sorted Objects in a Container that Enables Fast Lookups
  • Problem
  • Solution
  • How It Works
  • Recipe 7-5. Storing Unsorted Elements in a Container for Very Fast Lookups
  • Problem
  • Solution
  • How It Works
  • Chapter 8: The STL Algorithms
  • Recipe 8-1. Using an iterator to Define a Sequence within a Container
  • Problem
  • Solution
  • How It Works
  • Recipe 8-2. Calling a Function on Every Element in a Container
  • Problem
  • Solution
  • How It Works
  • Solution
  • How It Works
  • Detecting the Number of Logical CPU Cores
  • Creating Threads
  • Cleaning Up After Threads
  • 11-2. Creating thread Scope Variables
  • Problem
  • Solution
  • How It Works
  • 11-3. Accessing Shared Objects Using Mutual Exclusion
  • Problem
  • Solution
  • How It Works
  • 11-4. Creating Threads that Wait for Events
  • Problem
  • Solution
  • How It Works
  • 11-5. Retrieving Results from a Thread
  • Problem
  • Solution
  • How It Works
  • Using the promise and future Classes
  • 11-6. Synchronizing Queued Messages between Threads
  • Problem
  • Solution
  • How It Works
  • Chapter 12: Networking
  • 12-1. Setting Up a Berkeley Sockets Application on OS X
  • Problem
  • Solution
  • How It Works
  • 12-2. Setting Up a Berkeley Sockets Application in Eclipse on Ubuntu
  • Problem
  • Solution
  • How It Works
  • 12-3. Setting Up a Winsock 2 Application in Visual Studio on Windows
  • Problem
  • Solution
  • How It Works
  • 12-4. Creating a Socket Connection between Two Programs
  • Problem
  • Solution
  • How It Works
  • 12-5. Creating a Networking Protocol between Two Programs
  • Problem
  • Solution
  • How It Works
  • Chapter 13: Scripting
  • 13-1. Creating a Lua Library Project in Visual Studio
  • Problem
  • Solution
  • How It Works
  • 13-2. Creating a Lua Library Project in Eclipse
  • Problem
  • Solution
  • How It Works
  • 13-3. Creating a Lua Project in Xcode
  • Problem
  • Solution
  • How It Works
  • 13-4. Using the Lua Programming Language
  • Problem
  • Solution
  • How It Works
  • Working with Variables
  • Working with Functions
  • Working with Tables
  • Using Flow Control
  • 13-5. Calling Lua Functions from C++
  • Problem
  • Solution
  • How It Works
  • 13-6. Calling C Functions from Lua
  • Problem
  • Solution
  • How It Works
  • 13-7. Creating Asynchronous Lua Functions
  • Problem
  • Solution
  • How It Works
  • Recipe 8-3. Finding the Maximum and Minimum Values in a Container
  • Problem
  • Solution
  • How It Works
  • Finding the Minimum Value in a Container
  • Finding the Maximum Values in a Container
  • Recipe 8-4. Counting Instances of a Value in a Sequence
  • Problem
  • Solution
  • How It Works
  • Recipe 8-5. Finding Values in a Sequence
  • Problem
  • Solution
  • How It Works
  • Recipe 8-6. Sorting Elements in a Sequence
  • Problem
  • Solution
  • How It Works
  • Chapter 9: Templates
  • 9-1. Creating a Template Function
  • Problem
  • Solution
  • How It Works
  • Creating a Template Function
  • Explicit vs. Implicit Template Specialization
  • 9-2. Partially Specializing a Template
  • Problem
  • Solution
  • How It Works
  • 9-3. Creating Class Templates
  • Problem
  • Solution
  • How It Works
  • 9-4. Creating Singletons
  • Problem
  • Solution
  • How It Works
  • 9-5. Calculating Values at Compile Time
  • Problem
  • Solution
  • How It Works
  • Chapter 10: Memory
  • 10-1. Using Static Memory
  • Problem
  • Solution
  • How It Works
  • 10-2. Using Stack Memory
  • Problem
  • Solution
  • How It Works
  • 10-3. Using Heap Memory
  • Problem
  • Solution
  • How It Works
  • 10-4. Using Automated Shared Memory
  • Problem
  • Solution
  • How It Works
  • 10-5. Creating Single-Instance Dynamic Objects
  • Problem
  • Solution
  • How It Works
  • 10-6. Creating Smart Pointers
  • Problem
  • Solution
  • How It Works
  • 10-7. Debugging Memory Problems by Overloading new and delete
  • Problem
  • Solution
  • How It Works
  • 10-8. Calculating Performance Impacts of Code Changes
  • Problem
  • Solution
  • How It Works
  • 10-9. Understanding the Performance Impacts of Memory Choices
  • Problem
  • Solution
  • How It Works
  • 10-10. Reducing Memory Fragmentation
  • Problem
  • Solution
  • How It Works
  • Chapter 11: Concurrency
  • 11-1. Using Threads to Execute Concurrent Tasks
  • Problem
  • At a Glance
  • Contents
  • About the Author
  • About the Technical Reviewers
  • Acknowledgments
  • Introduction
  • Chapter 1: Beginning C++
  • Recipe 1-1. Finding a Text Editor
  • Problem
  • Solution
  • Recipe 1-2. Installing Clang on Ubuntu
  • Problem
  • Solution
  • How It Works
  • Recipe 1-3. Installing Clang on Windows
  • Problem
  • Solution
  • How It Works
  • Recipe 1-4. Installing Clang on OS X
  • Problem
  • Solution
  • How It Works
  • Recipe 1-5. Building Your First C++ Program
  • Problem
  • Solution
  • Recipe 1-6. Debugging C++ programs using GDB in Cygwin or Linux
  • Problem
  • Solution
  • How It Works
  • Recipe 1-7. Debugging Your C++ Programs on OS X
  • Problem
  • Solution
  • How It Works
  • Recipe 1-8. Switching C++ Compilation Modes
  • Problem
  • Solution
  • How It Works
  • Recipe 1-9. Building with the Boost Library
  • Problem
  • Solution
  • How It Works
  • Chapter 2: Modern C++
  • Recipe 2-1. Initializing Variables
  • Problem
  • Solution
  • How It Works
  • Recipe 2-2. Initializing Objects with Initializer Lists
  • Problem
  • Solution
  • How It Works
  • Recipe 2-3. Using Type Deduction
  • Problem
  • Solution
  • How It Works
  • Recipe 2-4. Using auto with Functions
  • Problem
  • Solution
  • How It Works
  • Recipe 2-5. Working with Compile Time Constants
  • Problem
  • Solution
  • How It Works
  • Recipe 2-6. Working with Lambdas
  • Problem
  • Solution
  • How It Works
  • Recipe 2-7. Working with Time
  • Problem
  • Solution
  • How It Works
  • Getting the Current Date and Time
  • Comparing Times
  • Recipe 2-8. Understanding lvalue and rvalue References
  • Problem
  • Solution
  • How It Works
  • Recipe 2-9. Using Managed Pointers
  • Problem
  • Solution
  • How It Works
  • Using unique_ptr
  • Using shared_ptr Instances
  • Using a weak_ptr
  • Chapter 3: Working with Text
  • Recipe 3-1. Representing Strings in Code Using Literals