std::copyable_function
| 헤더 <functional>
|
||
template< class... >
class copyable_function; // not defined
|
에 정의됨 (1) | (C++26부터) |
template< class R, class... Args >
class copyable_function<R(Args...)>;
template< class R, class... Args >
class copyable_function<R(Args...) noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) &>;
template< class R, class... Args >
class copyable_function<R(Args...) & noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) &&>;
template< class R, class... Args >
class copyable_function<R(Args...) && noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) const>;
template< class R, class... Args >
class copyable_function<R(Args...) const noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) const &>;
template< class R, class... Args >
class copyable_function<R(Args...) const & noexcept>;
template< class R, class... Args >
class copyable_function<R(Args...) const &&>;
template< class R, class... Args >
class copyable_function<R(Args...) const && noexcept>;
|
(2) | (C++26부터) |
클래스 템플릿 std::copyable_function은 일반적인 다형성 함수 래퍼입니다. std::copyable_function 객체는 모든 복사 생성 가능 호출 가능 대상 — 함수, 람다 표현식, 바인드 표현식, 또는 기타 함수 객체, 그리고 멤버 함수에 대한 포인터와 멤버 객체에 대한 포인터를 저장하고 호출할 수 있습니다.
저장된 호출 가능 객체를 의 대상std::copyable_function이라고 합니다. std::copyable_function에 대상이 없으면 비어 있음이라고 합니다. std::function과 달리, 비어 있음 std::copyable_function을 호출하면 정의되지 않은 동작이 발생합니다.
std::copyable_functions는 템플릿 매개변수에 제공된 cv-한정자 (volatile 제외), 참조 한정자, 및 noexcept 지정자의 모든 가능한 조합을 지원합니다. 이러한 한정자와 지정자(있는 경우)는 operator()에 추가됩니다.
std::copyable_function는 복사 생성 가능 및 복사 할당 가능의 요구 사항을 충족합니다.
멤버 타입
| 타입 | 정의 |
result_type
|
R
|
멤버 함수
새로운
std::copyable_function
객체를 생성함
(public member function) |
|
std::copyable_function
객체를 파괴함
(public member function) |
|
|
대상을 교체하거나 파괴함
(public member function) |
|
두
std::copyable_function
객체의 대상을 교환함
(public member function) |
|
std::copyable_function
이 대상을 가지고 있는지 확인함
(public member function) |
|
|
대상을 호출함
(public member function) |
비멤버 함수
|
(C++26)
|
std::swap
알고리즘을 오버로드함
(함수) |
|
(C++26)
|
std::copyable_function
을
nullptr
와 비교함
(함수) |
참고 사항
구현체는 작은 크기의 호출 가능 객체를
std::copyable_function
객체 내에 저장할 수 있습니다. 이러한 작은 객체 최적화는 함수 포인터와
std::reference_wrapper
특수화에 대해 사실상 요구되며,
T
타입에 대해서만 적용될 수 있습니다. 이때
std::
is_nothrow_move_constructible_v
<
T
>
가
true
인 경우에만 적용 가능합니다.
| 기능 테스트 매크로 | 값 | 표준 | 기능 |
|---|---|---|---|
__cpp_lib_copyable_function
|
202306L
|
(C++26) |
std::copyable_function
|
예제
|
이 섹션은 불완전합니다
이유: 예제가 없음 |
참고 항목
|
(C++11)
|
복사 생성 가능한 모든 호출 가능 객체의 복사 가능 래퍼
(클래스 템플릿) |
|
(C++23)
|
주어진 호출 시그니처에서 한정자를 지원하는 모든 호출 가능 객체의 이동 전용 래퍼
(클래스 템플릿) |
|
(C++26)
|
모든 호출 가능 객체의 비소유 래퍼
(클래스 템플릿) |