Standard library header <utility>
From cppreference.net
이 헤더는 범용 유틸리티 라이브러리의 일부입니다.
포함 파일 |
||
|
(C++20)
|
3방향 비교 연산자 지원 | |
|
(C++11)
|
std::initializer_list 클래스 템플릿 | |
네임스페이스 |
||
rel_ops
|
자동 비교 연산자 제공 | |
|
다음 네임스페이스에 정의됨
std::rel_ops
|
||
|
(C++20에서 사용 중단됨)
|
사용자 정의
operator
==
및
operator
<
기반으로 비교 연산자를 자동 생성함
(함수 템플릿) |
|
함수 |
||
|
두 객체의 값을 교환합니다
(함수 템플릿) |
||
|
(C++14)
|
인수를 새 값으로 교체하고 이전 값을 반환합니다
(함수 템플릿) |
|
|
(C++11)
|
함수 인자를 전달하고 타입 템플릿 인자를 사용하여 값 범주를 보존함
(function template) |
|
|
(C++23)
|
지정된 타입 템플릿 인자의 표현식 값 범주와 constness로 캐스팅하는 것처럼 함수 인자를 전달합니다
(함수 템플릿) |
|
|
(C++11)
|
인수를 xvalue로 변환합니다
(함수 템플릿) |
|
|
(C++11)
|
이동 생성자가 예외를 던지지 않는 경우 인수를 xvalue로 변환합니다
(함수 템플릿) |
|
|
(C++17)
|
인수에 대한
const
참조를 얻음
(함수 템플릿) |
|
|
(C++11)
|
평가되지 않는 컨텍스트에서 사용하기 위해 템플릿 타입 인자의 객체에 대한 참조를 얻음
(function template) |
|
|
(C++23)
|
열거형을 해당 기반 타입으로 변환
(함수 템플릿) |
|
|
두 정수 값을 비교하며, 부호 있는 음수가 부호 없는 숫자보다 작도록 보장합니다
(함수 템플릿) |
||
|
(C++20)
|
정수 값이 주어진 정수 타입의 범위 내에 있는지 확인합니다
(함수 템플릿) |
|
|
(C++23)
|
실행 불가능한 지점을 표시합니다
(함수) |
|
인자 타입에 의해 결정된 타입의
pair
객체를 생성합니다
(함수 템플릿) |
||
|
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20)
|
pair
내의 값들을 사전식으로 비교합니다
(함수 템플릿) |
|
|
(C++11)
|
std::swap
알고리즘을 특수화함
(함수 템플릿) |
|
|
(C++11)
|
pair
의 요소에 접근합니다
(함수 템플릿) |
|
클래스 |
||
|
이진 튜플, 즉 두 값의 쌍을 구현합니다
(클래스 템플릿) |
||
|
(C++11)
|
튜플과 유사한 타입의 요소 개수를 구함
(클래스 템플릿) |
|
|
(C++11)
|
튜플과 유사한 타입의 요소 타입들을 얻음
(클래스 템플릿) |
|
|
(C++11)
|
pair
의 크기를 구함
(클래스 템플릿 특수화) |
|
|
(C++11)
|
pair
의 요소 타입을 획득합니다
(클래스 템플릿 특수화) |
|
|
(C++14)
|
정수들의 컴파일 타임 시퀀스를 구현함
(클래스 템플릿) |
|
전방 선언 |
||
|
헤더 파일에 정의됨
<tuple>
|
||
|
(C++11)
|
서로 다른 타입의 요소들을 보관하는 고정 크기 컨테이너를 구현
(클래스 템플릿) |
|
|
헤더에 정의됨
<variant>
|
||
|
(C++17)
|
기본 생성 불가능한 타입들의
variant
에서 첫 번째 대안으로 사용하기 위한 플레이스홀더 타입
(클래스) |
|
상수 |
||
|
(C++11)
|
tuple
을
tie
로 언패킹할 때 요소를 건너뛰기 위한 플레이스홀더
(상수) |
|
태그 |
||
|
피스와이즈 생성 태그
(태그) |
||
|
인-플레이스 생성 태그
(태그) |
||
|
(C++26)
|
값 생성 태그
(태그) |
|
시놉시스
#include <compare> #include <initializer_list> namespace std { // swap template<class T> constexpr void swap(T& a, T& b) noexcept(/* 설명 참조 */); template<class T, size_t N> constexpr void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v<T>); // exchange template<class T, class U = T> constexpr T exchange(T& obj, U&& new_val); // forward/move template<class T> constexpr T&& forward(remove_reference_t<T>& t) noexcept; template<class T> constexpr T&& forward(remove_reference_t<T>&& t) noexcept; template<class T, class U> constexpr /* 설명 참조 */ forward_like(U&& x) noexcept; template<class T> constexpr remove_reference_t<T>&& move(T&&) noexcept; template<class T> constexpr conditional_t< !is_nothrow_move_constructible_v<T> && is_copy_constructible_v<T>, const T&, T&&> move_if_noexcept(T& x) noexcept; // as_const template<class T> constexpr add_const_t<T>& as_const(T& t) noexcept; template<class T> void as_const(const T&&) = delete; // declval template<class T> add_rvalue_reference_t<T> declval() noexcept; // 평가되지 않은 피연산자로서 // 정수 비교 함수들 template<class T, class U> constexpr bool cmp_equal(T t, U u) noexcept; template<class T, class U> constexpr bool cmp_not_equal(T t, U u) noexcept; template<class T, class U> constexpr bool cmp_less(T t, U u) noexcept; template<class T, class U> constexpr bool cmp_greater(T t, U u) noexcept; template<class T, class U> constexpr bool cmp_less_equal(T t, U u) noexcept; template<class T, class U> constexpr bool cmp_greater_equal(T t, U u) noexcept; template<class R, class T> constexpr bool in_range(T t) noexcept; // to_underlying template<class T> constexpr underlying_type_t<T> to_underlying(T value) noexcept; // 도달할 수 없음 [[noreturn]] void unreachable(); // 컴파일 타임 정수 시퀀스 template<class T, T...> struct integer_sequence; template<size_t... I> using index_sequence = integer_sequence<size_t, I...>; template<class T, T N> using make_integer_sequence = integer_sequence<T, /* 설명 참조 */>; template<size_t N> using make_index_sequence = make_integer_sequence<size_t, N>; template<class... T> using index_sequence_for = make_index_sequence<sizeof...(T)>; // class template pair template<class T1, class T2> struct pair; // pair 전용 알고리즘 template<class T1, class T2> constexpr bool operator==(const pair<T1, T2>&, const pair<T1, T2>&); template<class T1, class T2> constexpr common_comparison_category_t</*synth-three-way-result*/<T1>, /*synth-three-way-result*/<T2>> operator<=>(const pair<T1, T2>&, const pair<T1, T2>&); template<class T1, class T2> constexpr void swap(pair<T1, T2>& x, pair<T1, T2>& y) noexcept(noexcept(x.swap(y))); template<class T1, class T2> constexpr /* 설명 참조 */ make_pair(T1&&, T2&&); // pair에 대한 tuple-like 접근 template<class T> struct tuple_size; template<size_t I, class T> struct tuple_element; template<class T1, class T2> struct tuple_size<pair<T1, T2>>; template<size_t I, class T1, class T2> struct tuple_element<I, pair<T1, T2>>; template<size_t I, class T1, class T2> constexpr tuple_element_t<I, pair<T1, T2>>& get(pair<T1, T2>&) noexcept; template<size_t I, class T1, class T2> constexpr tuple_element_t<I, pair<T1, T2>>&& get(pair<T1, T2>&&) noexcept; template<size_t I, class T1, class T2> constexpr const tuple_element_t<I, pair<T1, T2>>& get(const pair<T1, T2>&) noexcept; template<size_t I, class T1, class T2> constexpr const tuple_element_t<I, pair<T1, T2>>&& get(const pair<T1, T2>&&) noexcept; template<class T1, class T2> constexpr T1& get(pair<T1, T2>& p) noexcept; template<class T1, class T2> constexpr const T1& get(const pair<T1, T2>& p) noexcept; template<class T1, class T2> constexpr T1&& get(pair<T1, T2>&& p) noexcept; template<class T1, class T2> constexpr const T1&& get(const pair<T1, T2>&& p) noexcept; template<class T2, class T1> constexpr T2& get(pair<T1, T2>& p) noexcept; template<class T2, class T1> constexpr const T2& get(const pair<T1, T2>& p) noexcept; template<class T2, class T1> constexpr T2&& get(pair<T1, T2>&& p) noexcept; template<class T2, class T1> constexpr const T2&& get(const pair<T1, T2>&& p) noexcept; // pair piecewise construction struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; inline constexpr piecewise_construct_t piecewise_construct{}; template<class... Types> class tuple; // <tuple>에 정의됨 // in-place construction struct in_place_t { explicit in_place_t() = default; }; inline constexpr in_place_t in_place{}; template<class T> struct in_place_type_t { explicit in_place_type_t() = default; }; template<class T> inline constexpr in_place_type_t<T> in_place_type{}; template<size_t I> struct in_place_index_t { explicit in_place_index_t() = default; }; template<size_t I> inline constexpr in_place_index_t<I> in_place_index{}; // 비타입 인수 태그 template<auto V> struct nontype_t { explicit nontype_t() = default; }; template<auto V> inline constexpr nontype_t<V> nontype{}; } // deprecated namespace std::rel_ops { template<class T> bool operator!=(const T&, const T&); template<class T> bool operator> (const T&, const T&); template<class T> bool operator<=(const T&, const T&); template<class T> bool operator>=(const T&, const T&); }
클래스 템플릿 std::integer_sequence
namespace std { template<class T, T... I> struct integer_sequence { using value_type = T; static constexpr size_t size() noexcept { return sizeof...(I); } }; }
클래스 템플릿 std::pair
namespace std { template<class T1, class T2> struct pair { using first_type = T1; using second_type = T2; T1 first; T2 second; pair(const pair&) = default; pair(pair&&) = default; constexpr explicit(/* 설명 참조 */) pair(); constexpr explicit(/* 설명 참조 */) pair(const T1& x, const T2& y); template<class U1 = T1, class U2 = T2> constexpr explicit(/* 설명 참조 */) pair(U1&& x, U2&& y); template<class U1, class U2> constexpr explicit(/* 설명 참조 */) pair(const pair<U1, U2>& p); template<class U1, class U2> constexpr explicit(/* 설명 참조 */) pair(pair<U1, U2>&& p); template<class... Args1, class... Args2> constexpr pair(piecewise_construct_t, tuple<Args1...> first_args, tuple<Args2...> second_args); constexpr pair& operator=(const pair& p); template<class U1, class U2> constexpr pair& operator=(const pair<U1, U2>& p); constexpr pair& operator=(pair&& p) noexcept(/* 설명 참조 */); template<class U1, class U2> constexpr pair& operator=(pair<U1, U2>&& p); constexpr void swap(pair& p) noexcept(/* 설명 참조 */); }; template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>; }
참고 항목
|
(C++11)
|
std::tuple 클래스 템플릿 |