C++ 11 features with complete examples🐿️🐿️

C++ 11 features with complete examples

This page summarises the features introduced in C++11, grouped by learning complexity, frequency of use, and conceptual depth. The goal is to guide developers through a structured learning path.

C++ 11 for Beginners

C++ 11 for Intermediate

  • Lambda expressions – Anonymous functions; essential for STL algorithms.
  • constexpr – Enables compile-time computations.
  • Defaulted/deleted functions – Explicit control of constructors and assignment operators.
  • Delegating constructors – Constructor reuse within a class.
  • Inheriting constructors – Automatically inherits base constructors.
  • Trailing return types – Return types after the parameter list using ->.
  • decltype – Deduces the type of an expression.
  • noexcept – Indicates whether a function throws.
  • Forward-declared scoped enums – Useful for large header-based designs.
  • STL additions: std::array, std::unordered_map, etc.

C++ 11 for Advanced

  • Rvalue references & move semantics – Enables efficient resource transfer.
  • Variadic templates – Functions/classes that accept a variable number of template arguments.
  • User-defined literals – Custom suffixes for literals (e.g., 42_km).
  • std::move and std::forward – Helpers for move semantics and perfect forwarding.
  • Smart pointers – std::unique_ptr, std::shared_ptr, std::weak_ptr.
  • std::tuple, std::bind, std::function – For generic and functional-style code.
  • Thread support: std::thread, std::mutex, std::lock_guard, etc.
  • std::chrono – Time utilities and duration handling.
  • std::regex – Regular expressions support.
  • Futures and async: std::future, std::async, std::promise.
  • <type_traits> – Template metaprogramming utilities.
  • std::begin, std::end – Range-based iteration support.