共用方式為


<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>

Remarks

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_element

A class that wraps the type of a pair element.

tuple_size

A class that wraps pair element count.

Functions

forward

Preserves the reference type (either lvalue or rvalue) of the argument from being obscured by perfect forwarding.

get

A function that gets an element from a pair object.

make_pair

A template helper function used to construct objects of type pair, where the component types are based on the data types passed as parameters.

move

Returns the passed in argument as an rvalue reference.

swap

Exchanges 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

pair

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

See Also

Reference

Thread Safety in the C++ Standard Library

Other Resources

C++ Standard Library Header Files