Namensräume
Varianten

std::function

Aus cppreference.com
Version vom 25. Oktober 2012, 23:28 Uhr von P12 (Diskussion | Beiträge) (1 Version: Translate from the English version)

<metanoindex/>

 
 
 
Function-Objekte
Funktionswrapper
function(C++11)
mem_fn(C++11)
bad_function_call(C++11)
Bindung
bind(C++11)
is_bind_expression(C++11)
is_placeholder(C++11)
_1, _2, _3, ...(C++11)
Referenzwrapper
reference_wrapper(C++11)
ref
cref
(C++11)
(C++11)
Operatorwrapper
Verneinung
Veraltete Binder und Adapter
unary_function(veraltet)
binary_function(veraltet)
ptr_fun(veraltet)
pointer_to_unary_function(veraltet)
pointer_to_binary_function(veraltet)
mem_fun(veraltet)
mem_fun_t
mem_fun1_t
const_mem_fun_t
const_mem_fun1_t
(veraltet)
(veraltet)
(veraltet)
(veraltet)
mem_fun_ref(veraltet)
mem_fun_ref_t
mem_fun1_ref_t
const_mem_fun_ref_t
const_mem_fun1_ref_t
(veraltet)
(veraltet)
(veraltet)
(veraltet)
binder1st
binder2nd
(veraltet)
(veraltet)
bind1st
bind2nd
(veraltet)
(veraltet)
 
 
Defined in header <functional>
template< class > class function; /* undefined */
(seit C++11)
template< class R, class... Args > class function<R(Args...)>
(seit C++11)
Vorlage Klasse std::function ist ein Allzweck-polymorphe Funktion Wrapper. Instanzen std::function speichern können, zu kopieren, und rufen alle kündbaren Ziel - Funktionen, Lambda-Ausdrücke, bind Ausdrücke oder andere Funktion Objekte .
Original:
Class template std::function is a general-purpose polymorphic function wrapper. Instances of std::function can store, copy, and invoke any callable target -- functions, Lambda-Ausdrücke, bind Ausdrücke, or other function objects.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Mitglied Typen

Type
Original:
Type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Definition
result_type R
argument_type
T wenn sizeof...(Args)==1 und T ist das erste und einzige in Args...
Original:
T if sizeof...(Args)==1 and T is the first and only type in Args...
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
first_argument_type
T1 wenn sizeof...(Args)==2 und T1 ist die erste der beiden Typen im Args...
Original:
T1 if sizeof...(Args)==2 and T1 is the first of the two types in Args...
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
second_argument_type
T2 wenn sizeof...(Args)==2 und T2 ist die zweite der beiden Typen im Args...
Original:
T2 if sizeof...(Args)==2 and T2 is the second of the two types in Args...
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Member-Funktionen

Vorlage:cpp/utility/functional/function/dcl list constructorVorlage:cpp/utility/functional/function/dcl list destructorVorlage:cpp/utility/functional/function/dcl list operator=Vorlage:cpp/utility/functional/function/dcl list swapVorlage:cpp/utility/functional/function/dcl list assignVorlage:cpp/utility/functional/function/dcl list operator boolVorlage:cpp/utility/functional/function/dcl list operator()Vorlage:cpp/utility/functional/function/dcl list target typeVorlage:cpp/utility/functional/function/dcl list target
Ziel zuzugreifen
Original:
Target access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Non-Member-Funktionen

Vorlage:cpp/utility/functional/function/dcl list swap2
vergleicht eine std::function mit std::nullptr
Original:
compares an std::function with std::nullptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(Funktions-Template)

Helper-Klassen

Vorlage:cpp/utility/functional/function/dcl list uses allocator

Beispiel

#include <functional>
#include <iostream>

struct Foo {
    Foo(int num) : num_(num) {}
    void print_add(int i) const { std::cout << num_+i << '\n'; }
    int num_;
};

void print_num(int i)
{
    std::cout << i << '\n';
}

int main()
{
    // store a free function
    std::function<void(int)> f_display = print_num;
    f_display(-9);

    // store a lambda
    std::function<void()> f_display_42 = []() { print_num(42); };
    f_display_42();

    // store the result of a call to std::bind
    std::function<void()> f_display_31337 = std::bind(print_num, 31337);
    f_display_31337();

    // store a call to a member function
    std::function<void(const Foo&, int)> f_add_display = &Foo::print_add;
    Foo foo(314159);
    f_add_display(foo, 1);
}

Output:

-9
42
31337
314160

Siehe auch

Vorlage:cpp/utility/functional/dcl list bad function callVorlage:cpp/utility/functional/dcl list mem fn