std::chrono::ambiguous_local_time
时间点 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时长 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时钟 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
当天时刻 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
日历 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
时区 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
chrono
I/O
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++20)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
C 风格日期和时间 |
在标头
<chrono>
定义
|
||
class
ambiguous_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::zoned_time 的 std::chrono::local_time 构造函数)抛出此异常。
继承图
成员函数
(构造函数)
|
构造异常对象 (公开成员函数) |
operator=
|
替换异常对象 (公开成员函数) |
what
|
返回解释字符串 (公开成员函数) |
std::chrono::ambiguous_local_time::ambiguous_local_time
template<
class
Duration >
ambiguous_local_time(const
std::chrono::local_time<Duration>&
tp, |
(1) | (C++20 起) |
ambiguous_local_time(
const
ambiguous_local_time&
other )
noexcept;
|
(2) | (C++20 起) |
构造异常对象。
what()
所返回的解释字符串等价于下列代码后 os.str()
所产生者:std::ostringstream os; os << tp << " is ambiguous. It could be\n" << tp << ' ' << i.first.abbrev << " == " << tp - i.first.offset << " UTC or\n" << tp << ' ' << i.second.abbrev << " == " << tp - i.second.offset << " UTC";
*this
与 other
均拥有动态类型
std::chrono::ambiguous_local_time
则 std::strcmp(what(), other.what()) == 0 。
参数
tp | - | 试图转换的时间点 |
i | - | 描述转换尝试的结果的 std::chrono::local_info |
other | - | 要复制的另一 ambiguous_local_time
|
异常
可能抛出 std::bad_alloc
注解
因为不容许复制派生自 std::exception
的标准库类抛出异常,此信息通常在内部存储为分离分配的引用计数字符串。
std::chrono::ambiguous_locale_time::operator=
ambiguous_locale_time&
operator=(
const
ambiguous_locale_time&
other )
noexcept;
|
(C++20 起) | |
以 other
的内容赋值。如果 *this 与
other
均拥有动态类型 std::chrono::ambiguous_locale_time
,那么赋值后
std::strcmp(what(), other.what()) == 0。
参数
other | - | 用来赋值的另一异常对象 |
返回值
*this
std::chrono::ambiguous_locale_time::what
virtual
const
char*
what()
const
noexcept;
|
(C++20 起) | |
返回解释字符串。
参数
(无)
返回值
指向有解释信息的空终止字符串的指针。该字符串适合转换并显示为 std::wstring。保证该指针至少到获得它来源的异常对象被销毁,或在该异常对象上调用非 const 成员函数(例如复制赋值运算符)为止合法。
注解
允许但不要求实现覆写 what()
。
继承自 std::exception
成员函数
[虚]
|
析构该异常对象 ( std::exception
的虚公开成员函数) |
[虚]
|
返回解释性字符串 ( std::exception
的虚公开成员函数) |