Namespaces
Variants

std:: copyable_function

From cppreference.net
Utilities library
Function objects
Function wrappers
(C++11)
copyable_function
(C++26)
(C++11)
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
헤더 파일에 정의됨 <functional>
template < class ... >
class copyable_function ; // 정의되지 않음
(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 객체는 CopyConstructible Callable 대상 — 함수, 람다 표현식 , 바인드 표현식 , 또는 기타 함수 객체들, 그리고 멤버 함수 포인터와 멤버 객체 포인터를 저장하고 호출할 수 있습니다.

저장된 호출 가능 객체는 std::copyable_function 대상 이라고 합니다. std::copyable_function 이 대상을 포함하지 않으면 비어 있음 이라고 합니다. std::function 과 달리, 비어 있는 std::copyable_function 을 호출하면 정의되지 않은 동작이 발생합니다.

std::copyable_function 은 템플릿 매개변수에 제공된 모든 가능한 조합의 cv-qualifiers ( volatile 제외), ref-qualifiers , 그리고 noexcept-specifiers 를 지원합니다. 이러한 qualifier와 specifier(있는 경우)는 해당 operator() 에 추가됩니다.

std::copyable_function CopyConstructible CopyAssignable 요구 사항을 충족합니다.

목차

멤버 타입

타입 정의
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)

비멤버 함수

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)
복사 생성 가능한 모든 호출 가능 객체의 복사 가능 래퍼
(클래스 템플릿)
주어진 호출 시그니처에서 한정자를 지원하는 모든 호출 가능 객체의 이동 전용 래퍼
(클래스 템플릿)
모든 호출 가능 객체의 비소유 래퍼
(클래스 템플릿)