std:: is_implicit_lifetime
| Type traits | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time rational arithmetic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Compile-time integer sequences | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
(C++14)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<type_traits>
|
||
|
template
<
class
T
>
struct is_implicit_lifetime ; |
(C++23 起) | |
std::is_implicit_lifetime
是一个
UnaryTypeTrait
。
如果
T
是
隐式生命周期类型
,则提供等于
true
的成员常量
value
。对于任何其他类型,
value
为
false
。
如果 T 是除数组类型或(可能带有 cv 限定符的) void 之外的不完整类型,则行为未定义。
如果程序为
std::is_implicit_lifetime
或
std::is_implicit_lifetime_v
添加特化,则行为是未定义的。
目录 |
模板参数
| T | - | 待检查的类型 |
辅助变量模板
|
template
<
class
T
>
constexpr bool is_implicit_lifetime_v = is_implicit_lifetime < T > :: value ; |
(C++23 起) | |
继承自 std:: integral_constant
成员常量
|
value
[static]
|
若
T
为隐式生命周期类型则为
true
,否则为
false
(公开静态成员常量) |
成员函数
|
operator bool
|
转换对象为
bool
类型,返回
value
(公开成员函数) |
|
operator()
(C++14)
|
返回
value
(公开成员函数) |
成员类型
| 类型 | 定义 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
注释
| 功能测试 宏 | 值 | 标准 | 功能 |
|---|---|---|---|
__cpp_lib_is_implicit_lifetime
|
202302L
|
(C++23) |
std::is_implicit_lifetime
|
示例
// 以下类型统称为隐式生命周期类型: // * 标量类型: // * 算术类型 // * 枚举类型 // * 指针类型 // * 成员指针类型 // * std::nullptr_t // * 隐式生命周期类类型 // * 是析构函数非用户提供的聚合体 // * 至少有一个平凡合格构造函数且具有平凡、非删除的析构函数 // * 数组类型 // * 这些类型的cv限定版本 #include <type_traits> static_assert(std::is_implicit_lifetime_v<int>); // 算术类型属于标量类型 static_assert(std::is_implicit_lifetime_v<const int>); // cv限定标量类型 enum E { e }; static_assert(std::is_implicit_lifetime_v<E>); // 枚举类型属于标量类型 static_assert(std::is_implicit_lifetime_v<int*>); // 指针类型属于标量类型 static_assert(std::is_implicit_lifetime_v<std::nullptr_t>); // 标量类型 struct S { int x, y; }; // S是隐式生命周期类:无用户提供析构函数的聚合体 static_assert(std::is_implicit_lifetime_v<S>); static_assert(std::is_implicit_lifetime_v<int S::*>); // 成员指针 struct X { ~X() = delete; }; // 由于析构函数被删除,X不是隐式生命周期类 static_assert(!std::is_implicit_lifetime_v<X>); static_assert(std::is_implicit_lifetime_v<int[8]>); // 数组类型 static_assert(std::is_implicit_lifetime_v<volatile int[8]>); // cv限定数组类型 int main() {}
参见
|
(C++11)
|
检查类型是否为标量类型
(类模板) |
|
(C++11)
|
检查类型是否为数组类型
(类模板) |
|
(C++17)
|
检查类型是否为聚合类型
(类模板) |
|
隐式在给定存储中创建对象并复用其对象表示
(函数模板) |