Namespaces
Variants

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

来自 zh.cppreference.net
 
 
 
函数对象
函数调用
(C++17)(C++23)
恒等函数对象
(C++20)
透明运算符包装器
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)

旧版绑定器和适配器
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)  
(直到 C++17*)
(直到 C++17*)(直到 C++17*)(直到 C++17*)(直到 C++17*)
(直到 C++20*)
(直到 C++20*)
(直到 C++17*)(直到 C++17*)
(直到 C++17*)(直到 C++17*)

(直到 C++17*)
(直到 C++17*)(直到 C++17*)(直到 C++17*)(直到 C++17*)
(直到 C++20*)
(直到 C++20*)
 
 
template< class F, class Alloc >
void assign( F&& f, const Alloc& alloc );
(C++11 起)
(C++17 移除)

用 目标 初始化 f。alloc 用于为 function 可能使用的任何内部数据结构分配内存。

等价于 function(std::allocator_arg, alloc, std::forward<F>(f)).swap(*this);。

参数

f - 用于初始化 target 的可调用函数
alloc - 用于为内部数据结构分配内存的分配器

返回值

(无)

异常

可能抛出实现定义的异常。

另请参阅

分配新的目标对象
(公开成员函数)