- functional[meta header]
- std[meta namespace]
- function[meta class]
- function template[meta id-type]
- cpp11[meta cpp]
- cpp17removed[meta cpp]
template <class F, class Alloc>
void assign(F&& f, const Alloc& alloc);
この機能は、C++17で削除された。このクラスでメモリアロケータを使用する必要はない。
関数オブジェクトとアロケータを再代入する。
function(allocator_arg, alloc, std::forward<F>(f)).swap(*this)
- function[link op_constructor.md]
- allocator_arg[link /reference/memory/allocator_arg_t.md]
- std::forward[link /reference/utility/forward.md]
- swap[link swap.md]
なし
#include <iostream>
#include <functional>
int ident(int x) { return x; }
int main()
{
std::function<int(int)> f;
// 関数とアロケータを代入。
//
// ※ここではint型を対象とするアロケータを渡しているが、
// 内部で適切な関数の型にrebindして使われる。
f.assign(ident, std::allocator<int>());
int result = f(1);
std::cout << result << std::endl;
}
- assign[color ff0000]
- f(1)[link op_call.md]
1
- C++11
- Clang: 3.0 [mark verified]
- GCC: 4.8.2 [mark noimpl]
- Visual C++: ??