<utility>

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at <utility>.

Defines Standard Template Library (STL) types, functions, and operators that help to construct and manage pairs of objects, which are useful whenever two objects need to be treated as if they were one.

#include <utility>  
  

Pairs are widely used in the Standard C++ Library. They are required both as the arguments and return values for various functions and as element types for containers such as map class and multimap class. The <utility> header is automatically included by <map> to assist in managing their key/value pair type elements.

Classes

tuple_elementA class that wraps the type of a pair element.
tuple_sizeA class that wraps pair element count.

Functions

forwardPreserves the reference type (either lvalue or rvalue) of the argument from being obscured by perfect forwarding.
getA function that gets an element from a pair object.
make_pairA template helper function used to construct objects of type pair, where the component types are based on the data types passed as parameters.
moveReturns the passed in argument as an rvalue reference.
swapExchanges the elements of two pair objects.

Operators

operator!=Tests if the pair object on the left side of the operator is not equal to the pair object on the right side.
operator==Tests if the pair object on the left side of the operator is equal to the pair object on the right side.
operator<Tests if the pair object on the left side of the operator is less than the pair object on the right side.
operator<=Tests if the pair object on the left side of the operator is less than or equal to the pair object on the right side.
operator>Tests if the pair object on the left side of the operator is greater than the pair object on the right side.
operator>=Tests if the pair object on the left side of the operator is greater than or equal to the pair object on the right side.

Structs

identity
pairA type that provides for the ability to treat two objects as a single object.

Header Files Reference
Thread Safety in the C++ Standard Library

Show: