Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Utility library

      From cppreference.com
      <cpp
       
       
      Utilities library
       

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

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

      Contents

      [edit]Language support

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

      [edit]Implementation properties(since C++20)

      The header<version> supplies implementation-dependent information about the C++ standard library (such as the version number and release date). It also defines thelibrary feature-test macros.

      [edit]Type support

      Basic types (e.g.std::size_t,std::nullptr_t), RTTI (e.g.std::type_info)

      [edit]Program utilities

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

      [edit]Dynamic memory management

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

      [edit]Error handling

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

      [edit]Variadic functions

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

      [edit]Initializer lists(since C++11)

      Defined in header<initializer_list>
      references a temporary array created inlist-initialization
      (class template)[edit]

      [edit]Source code information capture(since C++20)

      Defined in header<source_location>
      a class representing information about the source code, such as file names, line numbers, and function names
      (class)[edit]

      [edit]Three-way comparison(since C++20)

      Defined in header<compare>
      specifies that operator<=> produces consistent result on given types
      (concept)[edit]
      the result type of 3-way comparison that supports all 6 operators, is not substitutable, and allows incomparable values
      (class)[edit]
      the result type of 3-way comparison that supports all 6 operators and is not substitutable
      (class)[edit]
      the result type of 3-way comparison that supports all 6 operators and is substitutable
      (class)[edit]
      named comparison functions
      (function)[edit]
      constrained function object implementingx<=> y
      (class)[edit]
      obtains the result type of the three-way comparison operator<=> on given types
      (class template)[edit]
      the strongest comparison category to which all of the given types can be converted
      (class template)[edit]
      performs 3-way comparison and produces a result of typestd::strong_ordering
      (customization point object)[edit]
      (C++20)
      performs 3-way comparison and produces a result of typestd::weak_ordering
      (customization point object)[edit]
      performs 3-way comparison and produces a result of typestd::partial_ordering
      (customization point object)[edit]
      performs 3-way comparison and produces a result of typestd::strong_ordering, even ifoperator<=> is unavailable
      (customization point object)[edit]
      performs 3-way comparison and produces a result of typestd::weak_ordering, even ifoperator<=> is unavailable
      (customization point object)[edit]
      performs 3-way comparison and produces a result of typestd::partial_ordering, even ifoperator<=> is unavailable
      (customization point object)[edit]

      [edit]Coroutine support(since C++20)

      Types forcoroutine support (e.g.std::coroutine_traits,std::coroutine_handle).

      [edit]Contract support(since C++26)

      Types forcontract support (e.g.std::contracts::contract_violation).

      [edit]General-purpose utilities

      [edit]Swap

      Defined in header<utility>
      swaps the values of two objects
      (function template)[edit]
      (C++14)
      replaces the argument with a new value and returns its previous value
      (function template)[edit]
      Defined in header<concepts>
      swaps the values of two objects
      (customization point object)[edit]

      [edit]Type operations(since C++11)

      Defined in header<utility>
      (C++11)
      forwards a function argument and use the type template argument to preserve its value category
      (function template)[edit]
      forwards a function argument as if casting it to the value category and constness of the expression of specified type template argument
      (function template)[edit]
      (C++11)
      converts the argument to an xvalue
      (function template)[edit]
      converts the argument to an xvalue if the move constructor does not throw
      (function template)[edit]
      (C++17)
      obtains a reference toconst to its argument
      (function template)[edit]
      (C++11)
      obtains a reference to an object of the template type argument for use in an unevaluated context
      (function template)[edit]
      converts an enumeration to its underlying type
      (function template)[edit]

      [edit]Integer comparison functions(since C++20)

      Defined in header<utility>
      compares two integer values, ensuring that signed negative numbers are less than unsigned numbers
      (function template)[edit]
      (C++20)
      checks if an integer value is in the range of a given integer type
      (function template)[edit]

      [edit]Relational operators(until C++20)

      Defined in header<utility>
      Defined in namespacestd::rel_ops
      automatically generates comparison operators based on user-definedoperator== andoperator<
      (function template)[edit]

      [edit]Construction tags(since C++11)

      Defined in header<utility>
      piecewise construction tag
      (tag)[edit]
      in-place construction tag
      (tag)[edit]
      value construction tag
      (tag)[edit]

      [edit]Pairs andtuples

      Defined in header<utility>
      implements binary tuple, i.e. a pair of values
      (class template)[edit]
      Defined in header<tuple>
      (C++11)
      implements fixed size container, which holds elements of possibly different types
      (class template)[edit]
      (C++17)
      calls a function with a tuple of arguments
      (function template)[edit]
      construct an object with a tuple of arguments
      (function template)[edit]
      Tuple protocol(since C++11)
      Defined in header<tuple>
      Defined in header<utility>
      Defined in header<array>
      Defined in header<ranges>
      Defined in header<complex>
      (C++11)
      obtains the number of elements of a tuple-like type
      (class template)[edit]
      obtains the element types of a tuple-like type
      (class template)[edit]

      [edit]Sum types and type erased wrappers(since C++17)

      Defined in header<optional>
      (C++17)
      a wrapper that may or may not hold an object
      (class template)[edit]
       
      Defined in header<expected>
      (C++23)
      a wrapper that contains either an expected or error value
      (class template)[edit]
       
      Defined in header<variant>
      (C++17)
      a type-safe discriminated union
      (class template)[edit]
       
      Defined in header<any>
      (C++17)
      objects that hold instances of anyCopyConstructible type
      (class)[edit]

      [edit]Bitset

      Defined in header<bitset>
      implements constant length bit array
      (class template)[edit]

      [edit]Bit manipulation(since C++20)

      The header<bit> provides several function templates to access, manipulate, and process individual bits and bit sequences. The byte ordering (endianness) of scalar types can be inspected viastd::endian facility.

      [edit]Function objects(since C++11)

      Partial function application (e.g.std::bind) and related utilities: utilities for binding such asstd::ref andstd::placeholders, polymorphic function wrappers:std::function, predefined functors (e.g.std::plus,std::equal_to), pointer-to-member to function convertersstd::mem_fn.

      [edit]Hash support(since C++11)

      Defined in header<functional>
      (C++11)
      hash function object
      (class template)[edit]

      [edit]See also

      C documentation forUtility library
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility&oldid=181850"

      [8]ページ先頭

      ©2009-2025 Movatter.jp