Templates

A template is a C++ entity that defines one of the following: a family of classes (class template), which may be nested classes a family of functions (function template), which may be member functions an alias to a family of types (alias template) (since C++11) a family of variables (variable template) (since C++14) Templates are parametrized by one or more template parameters, of three kinds: type template parameters, non-type template parameters, and template template parameters. Wh

Template parameters and template arguments

Every template is parametrized by one or more template parameters, indicated in the parameter-list of the template declaration syntax: template < parameter-list > declaration (1) Each parameter in parameter-list may be: a non-type template parameter; a type template parameter; a template template parameter. Non-type template parameter type name(optional) (1) type name(optional) = default (2) type ... name(optional) (3) (since C++11) 1) A non-type t

template

Usage Declaration of a template Inside a template definition, template can be used to declare that a dependent name is a template.

Template argument deduction

In order to instantiate a function template, every template argument must be known, but not every template argument has to be specified. When possible, the compiler will deduce the missing template arguments from the function arguments. This occurs when a function call is attempted, when an address of a function template is taken, and in some other contexts: template<typename To, typename From> To convert(From f); void g(double d) { int i = convert<int>(d); // calls convert&l

system_error

This header is part of the error handling library. Classes error_category (C++11) base class for error categories (class) generic_category (C++11) identifies the generic error category (function) system_category (C++11) identifies the operating system error category (function) error_condition (C++11) holds a portable error code (class) errc (C++11) the std::error_condition enumeration listing all standard <cerrno> macro constants (class) error_code

switch

Usage switch statement: as the declaration of the statement

Swappable

Any lvalue or rvalue of this type can be swapped with any lvalue or rvalue of some other type, using unqualified function call swap() in the context where both std::swap and the user-defined swap()s are visible. Requirements Type U is swappable with type T if, for any object u of type U and any object t of type T, Expression Requirements Semantics #include <utility>using std::swap; swap(u, t); After the call, the value of t is the value held by u before the call, and the value of u

struct

Usage declaration of a compound type declaration of a scoped enumeration type (since C++11) If a function or a variable exists in scope with the name identical to the name of a non-union class type, struct can be prepended to the name for disambiguation, resulting in an elaborated type specifier

switch statement

Transfers control to one of the several statements, depending on the value of a condition. Syntax attr(optional) switch ( condition ) statement attr(C++11) - any number of attributes condition - any expression of integral or enumeration type, or of a class type contextually implicitly convertible to an integral or enumeration type, or a declaration of a single non-array variable of such type with a brace-or-equals initializer. statement - any statement (typically a c

Strings library

The C++ strings library includes support for two general types of strings: std::basic_string - a templated class designed to manipulate strings of any character type. Null-terminated strings - arrays of characters terminated by a special null character. std::basic_string The templated class std::basic_string generalizes how sequences of characters are manipulated and stored. String creation, manipulation, and destruction are all handled by a convenient set of class methods and relate