Namespaces
Variants

std::copyable_function:: copyable_function

From cppreference.net
Utilities library
Function objects
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* )
copyable_function ( ) noexcept ;
(1) (C++26부터)
copyable_function ( std:: nullptr_t ) noexcept ;
(2) (C++26부터)
copyable_function ( const copyable_function & other ) ;
(3) (C++26부터)
copyable_function ( copyable_function && other ) noexcept ;
(4) (C++26부터)
template < class F >
copyable_function ( F && f ) ;
(5) (C++26부터)
template < class T, class ... CArgs >
explicit copyable_function ( std:: in_place_type_t < T > , CArgs && ... args ) ;
(6) (C++26부터)
template < class T, class U, class ... CArgs >

explicit copyable_function ( std:: in_place_type_t < T > ,

std:: initializer_list < U > il, CArgs && ... args ) ;
(7) (C++26부터)

새로운 std::copyable_function 을 생성합니다.

1,2) 기본 생성자와 nullptr 를 받는 생성자는 빈 std::copyable_function 을 생성합니다.
3) 복사 생성자는 std::copyable_function 의 대상이 other 의 대상의 복사본인 std::copyable_function 을 생성합니다. 그렇지 않으면, other 가 비어 있는 경우 빈 std::copyable_function 을 생성합니다.
4) 이동 생성자는 std::copyable_function 의 대상이 other 인 대상을 가지는 객체를 생성합니다. other 는 이동 생성 후 유효하지만 지정되지 않은 상태가 됩니다.
5) VT std:: decay_t < F > 라고 하자. 만약 f 가 null 함수 포인터, null 멤버 포인터 값, 또는 빈 std::copyable_function (다른 특수화일 수 있음)인 경우, 빈 std::copyable_function 을 생성한다. 그렇지 않으면, 대상이 VT 타입이며 std:: forward < F > ( f ) 로 직접-비목록-초기화된 std::copyable_function 을 생성한다.
6) VT std:: decay_t < T > 로 정의합니다. 대상이 VT 타입이고 args... 를 사용하여 std:: forward < CArgs > ( args ) ... 로 직접-비목록-초기화된 std::copyable_function 을 생성합니다.
  • 이 오버로드는 std:: is_constructible_v < VT, CArgs... > /*is-callable-from*/ < VT > (아래 참조) 모두가 true 인 경우에만 오버로드 해결에 참여합니다.
  • VT T 와 동일한 타입이 아니거나 std:: is_copy_constructible_v < VT > true 가 아닌 경우 프로그램의 형식이 올바르지 않습니다.
7) VT std:: decay_t < T > 로 정의합니다. 대상이 VT 타입이고 il, std::forward<CArgs>(args)... 로 직접-비목록-초기화된 std::copyable_function 을 생성합니다.

생성자 (5-7) 의 경우, VT Destructible CopyConstructible 요구 사항을 모두 만족하지 않으면 동작이 정의되지 않습니다.

상수 /*is-callable-from*/ < VT > std::copyable_function 의 템플릿 매개변수에 있는 cv , ref , 그리고 noex 에 따라 아래와 같이 의존적입니다:

cv ref noexcept ( noex ) /*호출-가능-여부*/ < VT >
noexcept ( false ) std:: is_invocable_r_v < R, VT, Args... > &&

std:: is_invocable_r_v < R, VT & , Args... >

noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT, Args... > &&

std:: is_nothrow_invocable_r_v < R, VT & , Args... >

const noexcept ( false ) std:: is_invocable_r_v < R, const VT, Args... > &&

std:: is_invocable_r_v < R, const VT & , Args... >

const noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT, Args... > &&

std:: is_nothrow_invocable_r_v < R, const VT & , Args... >

& noexcept ( false ) std:: is_invocable_r_v < R, VT & , Args... >
& noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT & , Args... >
const & noexcept ( false ) std:: is_invocable_r_v < R, const VT & , Args... >
const & noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT & , Args... >
&& noexcept ( false ) std:: is_invocable_r_v < R, VT, Args... >
&& noexcept ( true ) std:: is_nothrow_invocable_r_v < R, VT, Args... >
const && noexcept ( false ) std:: is_invocable_r_v < R, const VT, Args... >
const && noexcept ( true ) std:: is_nothrow_invocable_r_v < R, const VT, Args... >

목차

매개변수

other - 복사 또는 이동할 다른 std::copyable_function
f - 래핑할 함수 또는 Callable 객체
args - 대상 객체를 생성하기 위한 인자들
il - std::initializer_list 대상 객체를 생성하기 위한 초기화자 목록

예외

3) 할당 실패 시 std::bad_alloc 을 throw하거나 대상 초기화에서 발생한 예외를 전파할 수 있습니다.
5-7) 할당 실패 시 std::bad_alloc 을 던지거나 대상 초기화에서 발생한 예외를 전파할 수 있습니다. VT 가 함수 포인터 타입이거나 std::reference_wrapper 의 특수화인 경우에는 예외가 발생하지 않습니다.

예제

참고 항목

새로운 std::function 인스턴스를 생성합니다
( std::function<R(Args...)> 의 public 멤버 함수)
새로운 std::move_only_function 객체를 생성합니다
( std::move_only_function 의 public 멤버 함수)