std::chrono:: nonexistent_local_time
|
定义于头文件
<chrono>
|
||
|
class
nonexistent_local_time
;
|
(C++20 起) | |
定义一种异常对象类型,用于报告试图将不存在的
std::chrono::local_time
转换为
std::chrono::sys_time
时未指定
std::chrono::choose
(例如
choose::earliest
或
choose::latest
)的情况。
此异常由 std::chrono::time_zone::to_sys 及调用它的函数(例如接收 std::chrono::local_time 参数的 std::chrono::zoned_time 构造函数)抛出。
继承关系图
目录 |
成员函数
|
(constructor)
|
构造异常对象
(公开成员函数) |
|
operator=
|
替换异常对象
(公开成员函数) |
|
what
|
返回说明性字符串
(公开成员函数) |
std::chrono::nonexistent_local_time:: nonexistent_local_time
|
template
<
class
Duration
>
nonexistent_local_time
(
const
std::
chrono
::
local_time
<
Duration
>
&
tp,
|
(1) | (since C++20) |
|
nonexistent_local_time
(
const
nonexistent_local_time
&
other
)
noexcept
;
|
(2) | (since C++20) |
构造异常对象。
what()
返回的说明字符串等效于执行以下代码后
os.str()
产生的结果:
std::ostringstream os; os << tp << " is in a gap between\n" << std::chrono::local_seconds(i.first.end.time_since_epoch()) + i.first.offset << ' ' << i.first.abbrev << " and\n" << std::chrono::local_seconds(i.second.begin.time_since_epoch()) + i.second.offset << ' ' << i.second.abbrev << " which are both equivalent to\n" << i.first.end << " UTC";
std::chrono::nonexistent_local_time
,则
std::
strcmp
(
what
(
)
, other.
what
(
)
)
==
0
。
参数
| tp | - | 尝试转换的时间点 |
| i | - | 描述转换尝试结果的 std::chrono::local_info |
| other | - |
要拷贝的另一个
nonexistent_local_time
|
异常
可能抛出 std::bad_alloc
注解
由于不允许拷贝派生自
std::exception
的标准库类时抛出异常,此消息通常作为单独分配的引用计数字符串内部存储。
std::chrono::nonexistent_locale_time:: operator=
|
nonexistent_locale_time
&
operator
=
(
const
nonexistent_locale_time
&
other
)
noexcept
;
|
(since C++20) | |
使用
other
的内容进行赋值。如果
*
this
和
other
都具有动态类型
std::chrono::nonexistent_locale_time
,则赋值后满足
std::
strcmp
(
what
(
)
, other.
what
(
)
)
==
0
。
参数
| other | - | 用于赋值的另一个异常对象 |
返回值
* this
std::chrono::nonexistent_locale_time:: what
|
virtual
const
char
*
what
(
)
const
noexcept
;
|
(since C++20) | |
返回解释性字符串。
返回值
指向一个由实现定义的、以空字符结尾的解释性字符串的指针。该字符串适合转换并显示为 std::wstring 。该指针保证至少在获取它的异常对象被销毁之前,或者在调用异常对象上的非const成员函数(例如拷贝赋值运算符)之前保持有效。
注解
实现允许但不要求重写
what()
。
继承自 std:: exception
成员函数
|
[virtual]
|
销毁异常对象
(
std::exception
的虚公开成员函数)
|
|
[virtual]
|
返回说明性字符串
(
std::exception
的虚公开成员函数)
|
参见
|
(C++20)
|
用于报告本地时间存在歧义的异常
(类) |