다음을 통해 공유


reference_wrapper 클래스

Wraps a reference.

template<class Ty>
    class reference_wrapper
    : public unary_function<T1, Ret>        // see below
    : public binary_function<T1, T2, Ret>   // see below
    {
public:
    typedef Ty type;
    typedef T0 result_type;                 // see below

    reference_wrapper(Ty&);

    Ty& get() const;
    operator Ty&() const;
    template<class T1, class T2, ..., class TN>
        typename result_of<T(T1, T2, ..., TN)>::type
        operator()(T1&, T2&, ..., TN&);

private:
    Ty *ptr; // exposition only
    };

설명

A reference_wrapper<Ty> is copy constructible and assignable, and holds a pointer that points to an object of type Ty.

A specialization reference_wrapper<Ty> is derived from std::unary_function<T1, Ret> (hence defining the nested type result_type as a synonym for Ret and the nested type argument_type as a synonym for T1) only if the type Ty is:

a function type or pointer to function type taking one argument of type T1 and returning Ret; or

a pointer to a member function Ret T::f() cv, where cv represents the member function's cv-qualifiers; the type T1 is cv T*; or

a class type that is derived from unary_function<T1, Ret>.

A specialization reference_wrapper<Ty> is derived from std::binary_function<T1, T2, Ret> (hence defining the nested type result_type as a synonym for Ret, the nested type first_argument_type as a synonym for T1, and the nested type second_argument_type as a synonym for T2) only if the type Ty is:

a function type or pointer to function type taking two arguments of types T1 and T2 and returning Ret; or

a pointer to a member function Ret T::f(T2) cv, where cv represents the member function's cv-qualifiers; the type T1 is cv T*; or

a class type that is derived from binary_function<T1, T2, Ret>.

생성자

reference_wrapper::reference_wrapper

reference_wrapper를 생성합니다.

형식 정의

reference_wrapper::result_type

The weak result type of the wrapped reference.

reference_wrapper::type

The type of the wrapped reference.

멤버 함수

reference_wrapper::get

Obtains the wrapped reference.

연산자

reference_wrapper::operator Ty&

Gets a pointer to the wrapped reference.

reference_wrapper::operator()

Calls the wrapped reference.

요구 사항

헤더: <기능>

네임스페이스: std

참고 항목

참조

cref 함수

ref 함수

기타 리소스

<functional> 멤버