Namespaces
Variants

std:: uses_allocator <std::function>

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
定义于头文件 <functional>
template < class R, class ... ArgTypes , class Alloc >
struct uses_allocator < std:: function < R ( ArgTypes... ) > , Alloc > : std:: true_type { } ;
(C++11 起)
(C++17 前)

std::uses_allocator 的特化用于告知其他库组件:所有 std::function 类型的对象均支持 使用分配器构造 ,即使它们不具有嵌套的 allocator_type

目录

注释

std::function 的分配器支持曾存在规范不明确且实现不一致的问题。部分实现完全不支持使用分配器构造,部分实现提供了必要的构造函数重载但忽略传入的分配器参数,还有部分实现虽提供重载并在构造时使用传入的分配器,但在 std::function 被重新赋值时不会使用该分配器。因此,C++17移除了分配器支持功能。

继承自 std:: integral_constant

成员常量

value
[static]
true
(公开静态成员常量)

成员函数

operator bool
转换为 bool 类型,返回 value
(公开成员函数)
operator()
(C++14)
返回 value
(公开成员函数)

成员类型

类型 定义
value_type bool
type std:: integral_constant < bool , value >

参见

检查指定类型是否支持使用分配器构造
(类模板)