##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# Utility library

From cppreference.com
< cpp

C++ includes a variety of utility libraries that provide functionality ranging from bit-counting to partial function application. These libraries can be broadly divided into two groups:

- language support libraries, and
- general-purpose libraries.

## [edit] Language support

Language support libraries provide classes and functions that interact closely with language features and support common language idioms.

### [edit] Type support

Basic types (e.g. std::size_t, std::nullptr_t), RTTI (e.g. std::type_info), type traits (e.g. std::is_integral, std::rank)

### [edit] Dynamic memory management

Smart pointers (e.g. std::shared_ptr), allocators (e.g. std::allocator), C-style memory management (e.g. std::malloc)

### [edit] Error handling

Exceptions (e.g. std::exception, std::logic_error), assertions (e.g. assert)

### [edit] Initializer lists

initializer_list (C++11) | allows the use of initializer list syntax to initialize non plain-old-data types (class template) [edit]

### [edit] Variadic functions

Support for functions that take an arbitrary number of parameters (via e.g. va_start, va_arg, va_end)

## [edit] General-purpose utilities

### [edit] Program utilities

Termination (e.g. std::abort, std::atexit), environment (e.g. std::system), signals (e.g. std::raise)

### [edit] Date and time

Time tracking (e.g. std::chrono::time_point, std::chrono::duration), C-style date and time (e.g. std::time, std::clock)

### [edit] Bitset

bitset | implements constant length bit array (class) [edit]

### [edit] Function objects

Partial function application (e.g. std::bind) and related utilities: utilities for binding such as std::ref and std::placeholders, polymorphic function wrappers: std::function, predefined functors (e.g. std::plus, std::equal_to), method to function converters std::mem_fn.

### [edit] Pairs and tuples

pair | implements binary tuple, i.e. a pair of values (class template) [edit]
tuple (C++11) | implements fixed size container, which holds elements of possibly different types (class template) [edit]
piecewise_construct_t (C++11) | tag type used to select correct function overload for piecewise construction (class) [edit]
piecewise_construct (C++11) | an object of type `piecewise_construct_t` used to disambiguate functions for piecewise construction (constant) [edit]
integer_sequence (C++14) | implements compile-time sequence of integers (class template) [edit]

### [edit] Swap, forward and move

swap | swaps the values of two objects (function template) [edit]
exchange (C++14) | replaces the argument with a new value and returns its previous value (function template) [edit]
forward (C++11) | forwards a function argument (function template) [edit]
move (C++11) | obtains an rvalue reference (function template) [edit]
move_if_noexcept (C++11) | obtains an rvalue reference if the move constructor does not throw (function template) [edit]
declval (C++11) | obtains the type of expression in unevaluated context (function template) [edit]

### [edit] Relational operators

Defined in namespace `std::rel_ops`
operator!=operator>operator<=operator>= | automatically generates comparison operators based on user-defined operator== and operator< (function template) [edit]

### [edit] Hash support

hash (C++11) | hash function object (class template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility&oldid=72368"