Namespaces
Variants

std::experimental::function<R(Args...)>:: function

From cppreference.net
function ( ) noexcept ;
(1) (라이브러리 fundamentals TS)
function ( std:: nullptr_t ) noexcept ;
(2) (라이브러리 fundamentals TS)
function ( const function & other ) ;
(3) (라이브러리 fundamentals TS)
function ( function && other ) ;
(4) (라이브러리 fundamentals TS)
template < class F >
function ( F f ) ;
(5) (라이브러리 fundamentals TS)
(6)
template < class Alloc >
function ( std:: allocator_arg_t , const Alloc & alloc ) noexcept ;
(라이브러리 펀더멘털 TS)
function ( std:: allocator_arg_t ,
const allocator_type & alloc ) noexcept ;
(라이브러리 펀더멘털 TS v3)
(7)
template < class Alloc >

function ( std:: allocator_arg_t , const Alloc & alloc,

std:: nullptr_t ) noexcept ;
(라이브러리 펀더멘털 TS)
function ( std:: allocator_arg_t , const allocator_type & alloc,
std:: nullptr_t ) noexcept ;
(라이브러리 펀더멘털 TS v3)
(8)
template < class Alloc >

function ( std:: allocator_arg_t , const Alloc & alloc,

const function & other ) ;
(라이브러리 펀더멘털 TS)
function ( std:: allocator_arg_t , const allocator_type & alloc,
const function & other ) ;
(라이브러리 펀더멘털 TS v3)
(9)
template < class Alloc >

function ( std:: allocator_arg_t , const Alloc & alloc,

function && other ) ;
(라이브러리 펀더멘털 TS)
function ( std:: allocator_arg_t , const allocator_type & alloc,
function && other ) ;
(라이브러리 펀더멘털 TS v3)
(10)
template < class F, class Alloc >
function ( std:: allocator_arg_t , const Alloc & alloc, F f ) ;
(라이브러리 fundamentals TS)
function ( std:: allocator_arg_t , const allocator_type & alloc, F f ) ;
(라이브러리 fundamentals TS v3)

다양한 소스로부터 std::experimental::function 을 생성합니다.

1,2) 함수를 생성합니다.
3) other target * this target 으로 복사합니다. other empty 상태이면, 호출 후 * this empty 상태가 됩니다.
4) other 대상 * this 대상 으로 이동합니다. other 비어 있는 경우, 호출 후 * this 비어 있는 상태가 됩니다. 생성 후, * this other. get_allocator ( ) 의 사본을 저장합니다. (library fundamentals TS v3)
5) target f 의 복사본으로 초기화합니다. 만약 f 가 함수에 대한 null 포인터이거나 멤버에 대한 null 포인터인 경우, 호출 후 * this empty 상태가 됩니다. 이 생성자는 f 가 인수 타입 Args... 와 반환 타입 R 에 대해 Callable 이 아닌 경우 오버로드 해결에 참여하지 않습니다.
6-10) (1-5) 와 동일하지만, alloc function 이 사용할 수 있는 내부 데이터 구조를 위한 메모리를 할당하는 데 사용된다는 점이 다릅니다. 이러한 생성자들은 alloc 를 타입 삭제 할당자(type-erased allocator)로 취급합니다 (아래 참조). (library fundamentals TS v3까지)

(1-5)를 통해 생성된 후, this - > get_memory_resource ( ) 는 생성 시점의 std:: experimental :: pmr :: get_default_resource ( ) 와 동일한 값을 반환합니다.

(library fundamentals TS)
(until library fundamentals TS v3)

(1-3) 및 (5)를 통해 생성된 후, * this 는 기본 생성된 std:: pmr :: polymorphic_allocator <> 를 저장합니다.

(library fundamentals TS v3)

target 이 함수 포인터나 std::reference_wrapper 인 경우, 소형 객체 최적화가 보장됩니다. 즉, 이러한 대상들은 항상 std::experimental::function 객체 내부에 직접 저장되며, 동적 할당이 발생하지 않습니다. 다른 대형 객체들은 동적으로 할당된 저장 공간에 생성되고 std::experimental::function 객체에 의해 포인터를 통해 접근될 수 있습니다.

함수 객체를 이동하거나 복사하는 생성자가, std::experimental::function 의 인스턴스를 포함하여, 존재하는 경우, 그 이동 또는 복사는 using-allocator construction 를 통해 할당자 this - > get_memory_resource ( ) (until library fundamentals TS v3) this - > get_allocator ( ) (library fundamentals TS v3) 를 사용하여 수행됩니다.

목차

타입 소거 할당자

function 의 생성자에서 할당자 인수 alloc 를 받는 경우, 해당 인수를 타입 삭제된 할당자로 취급합니다. function 이 메모리를 할당하는 데 사용하는 메모리 리소스 포인터는 (지정된 경우) 할당자 인수를 사용하여 다음과 같이 결정됩니다:

alloc
타입
메모리 리소스 포인터 값
존재하지 않음 (생성 시 allocator 지정되지 않음) 생성 시점의 std:: experimental :: pmr :: get_default_resource ( )
std::nullptr_t 생성 시점의 std:: experimental :: pmr :: get_default_resource ( )
std:: experimental :: pmr :: memory_resource * 로 변환 가능한
포인터 타입
static_cast < std:: experimental :: pmr :: memory_resource * > ( alloc )
std::experimental::pmr::polymorphic_allocator
특수화
alloc. resource ( )
Allocator 요구사항을 만족하는
다른 모든 타입
std:: experimental :: pmr :: resource_adaptor < A > ( alloc ) 타입 값에 대한 포인터,
여기서 A alloc 의 타입입니다.
포인터는 function 객체의 수명 동안에만 유효합니다.
위의 어떤 경우에도 해당하지 않음 프로그램의 형식이 잘못됨

매개변수

other - 초기화에 사용되는 함수 객체 * this
f - 초기화에 사용되는 호출 가능 객체 * this
alloc - 내부 메모리 할당에 사용되는 할당자
타입 요구사항
-
F Callable CopyConstructible 요구사항을 충족해야 합니다.

예외

3,8) other target 이 함수 포인터나 std::reference_wrapper 인 경우 예외를 던지지 않으며, 그렇지 않은 경우 std::bad_alloc 이나 저장된 호출 가능 객체의 복사 생성자에 의해 던져지는 예외를 던질 수 있습니다.
4) (없음)
5,10) f 가 함수 포인터이거나 std::reference_wrapper 인 경우에는 예외를 던지지 않으며, 그렇지 않은 경우에는 std::bad_alloc 이나 저장된 호출 가능 객체의 복사 생성자에 의해 던져지는 모든 예외를 던질 수 있습니다.
9) (없음)

예제