📖
Go C++
  • Introduction
  • Chapter 1: What You Must Know First
    • Virtual Address Space of Process: Memory Partition and Layout
    • Function Call: Stack Frame
    • Program Compiling and Linking
  • Chapter 2: C++ Basics Improvement
    • Default Parameters
    • Inline Function
    • Function Overloading
    • new and delete
    • const and Pointers
    • References in Detail
  • Chapter 3: Object-Oriented Principles
  • Class and Object
  • Constructor and Destructor
  • Shallow Copy and Deep Copy
  • Initializer List
  • Various Member Functions
  • Pointer to Class Members
  • Chapter 4: Template Programming
  • Function Templates
  • Class Templates
  • Memory Allocators
  • Chapter 5: Operator Overloading
    • Operator Overloading
    • Introduction to Iterators
    • Issues of Iterator Invalidation
    • More about new and delete
    • Overloading of new and delete: Object Pool
  • Chapter 6: Inheritance and Polymorphism
    • Look inside Inheritance
    • More about Inheritance
    • Virtual Functions, Static Binding and Dynamic Binding
    • More about Virtual Functions
    • Understanding Polymorphism
    • Abstract Classes
    • Frequently Asked Interview Questions: Polymorphism
  • Chapter 7: Multiple Inheritance
    • Virtual Inheritance and Virtual Base Classes
    • Diamond Problem
    • Four Kinds of Type Conversions
  • Chapter 8: Standard Template Library
    • Sequence Containers
    • Container Adaptors
    • Associative Containers
    • More about Iterators
    • Function Objects
    • Generic Algorithms, Binders and Lambda Expressions
  • Chapter 9: Object Optimization
    • Behind the Object
    • Optimizing Objects in Functions
    • Member Functions with Rvalue References
    • Move Semantics and Perfect Forwarding
  • Chapter 10: Smart Pointers
    • Smart Pointers
    • Smart Pointers without Reference Counting
    • Smart Pointers with Reference Counting
    • Custom Deleters
  • Chapter 11: Function Objects and Binders
    • More about Binders
    • Introduction to std::function
    • Template Specialization and Argument Deduction
    • More about std::function
    • std::bind(): A Simple Thread Pool
    • More about Lambda Expressions
  • Chapter 12: Multithreading
    • Important Features in C++11
    • Multithreaded Programming with std::thread
    • Mutual Exclusion
    • Producer-Consumer Problem
    • Atomic Operations
    • Thread Visibility and volatile
  • Chapter 13: Design Patterns
    • Singleton Pattern
    • Factory Pattern
    • Proxy Pattern
    • Decorator Pattern
    • Adapter Pattern
    • Observer Pattern
Powered by GitBook
On this page
  • Keywords and Syntax
  • Smart Pointers
  • Function Objects and Binders
  • Containers
  • Multithreading

Was this helpful?

  1. Chapter 12: Multithreading

Important Features in C++11

So far, we have already learnt most of the commonly used C++ features. Many of them are introduced in C++11 standard. Here we sum up a list of some important features in C++11.

Keywords and Syntax

  • auto: A type identifier that can automatically derives the type from the right side of operator =.

  • nullptr: A specialized keyword that refers to a NULL pointer.

  • For each: Traverse the container. The syntax is for(element: containter). Underlying implementation is iterators.

  • Rvalue reference &&: A reference to a Rvalue. It supports move semantics std::move() and perfect forwarding std::forwar().

  • ...: Templates with variable number of paramters.

Smart Pointers

shared_ptr: A pointer with reference counting. Multiple pointers can point to a same object.

weak_ptr: A observer pointer which will not change the reference count of the recourse, but can only examine if the object exists or not.

Function Objects and Binders

std::function: A powerful class able to bind a function with a function object.

std::bind(): Binds the parameters in a function, and returns a function object.

Lambda expressions: Anonymous functions that can serve as a function object without being given a name.

Containers

unordered_set: A associative container storing keys. Its underlying implementation is a hash map.

unordered_map: A associative container storing key-value pairs. Its underlying implementation is a hash map.

array: An array container. Unlike vector, the size of the array is immutable.

forward_list: A single linked list. list is a double linked list.

Multithreading

Previous C++ standard doesn't support language-level thread library. Since different operating system has different thread API, there are troubles when writing cross-platform codes. Now C++11 has its own thread support library which is very easy to use. In this chapter we will introduce threads, locks and atomic operations in C++.

PreviousMore about Lambda ExpressionsNextMultithreaded Programming with std::thread

Last updated 5 years ago

Was this helpful?